From 49c12ef4be229bf2223139298766ef441b075fbc Mon Sep 17 00:00:00 2001 From: Fred Sauer Date: Tue, 11 Jun 2013 11:18:19 -0700 Subject: [ticket/11606] remove preg_replace() /e modifier in make_clickable() PHPBB3-11606 --- phpBB/includes/functions_content.php | 49 +++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 14 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index c54cc25f34..9b8ba98bec 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -727,37 +727,58 @@ function make_clickable($text, $server_url = false, $class = 'postlink') $server_url = generate_board_url(); } - static $magic_url_match; - static $magic_url_replace; static $static_class; + static $magic_url_match_args; - if (!is_array($magic_url_match) || $static_class != $class) + if (!is_array($magic_url_match_args) || $static_class != $class) { $static_class = $class; $class = ($static_class) ? ' class="' . $static_class . '"' : ''; $local_class = ($static_class) ? ' class="' . $static_class . '-local"' : ''; - $magic_url_match = $magic_url_replace = array(); - // Be sure to not let the matches cross over. ;) + $magic_url_match_args = array(); // relative urls for this board - $magic_url_match[] = '#(^|[\n\t (>.])(' . preg_quote($server_url, '#') . ')/(' . get_preg_expression('relative_url_inline') . ')#ie'; - $magic_url_replace[] = "make_clickable_callback(MAGIC_URL_LOCAL, '\$1', '\$2', '\$3', '$local_class')"; + $magic_url_match_args[] = array( + '#(^|[\n\t (>.])(' . preg_quote($server_url, '#') . ')/(' . get_preg_expression('relative_url_inline') . ')#i', + MAGIC_URL_LOCAL, + $local_class, + ); // matches a xxxx://aaaaa.bbb.cccc. ... - $magic_url_match[] = '#(^|[\n\t (>.])(' . get_preg_expression('url_inline') . ')#ie'; - $magic_url_replace[] = "make_clickable_callback(MAGIC_URL_FULL, '\$1', '\$2', '', '$class')"; + $magic_url_match_args[] = array( + '#(^|[\n\t (>.])(' . get_preg_expression('url_inline') . ')#i', + MAGIC_URL_FULL, + $class, + ); // matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing - $magic_url_match[] = '#(^|[\n\t (>])(' . get_preg_expression('www_url_inline') . ')#ie'; - $magic_url_replace[] = "make_clickable_callback(MAGIC_URL_WWW, '\$1', '\$2', '', '$class')"; + $magic_url_match_args[] = array( + '#(^|[\n\t (>])(' . get_preg_expression('www_url_inline') . ')#i', + MAGIC_URL_WWW, + $class, + ); // matches an email@domain type address at the start of a line, or after a space or after what might be a BBCode. - $magic_url_match[] = '/(^|[\n\t (>])(' . get_preg_expression('email') . ')/ie'; - $magic_url_replace[] = "make_clickable_callback(MAGIC_URL_EMAIL, '\$1', '\$2', '', '')"; + $magic_url_match_args[] = array( + '/(^|[\n\t (>])(' . get_preg_expression('email') . ')/i', + MAGIC_URL_EMAIL, + '', + ); } - return preg_replace($magic_url_match, $magic_url_replace, $text); + foreach ($magic_url_match_args as $magic_args) + { + if (preg_match($magic_args[0], $text, $matches)) + { + $text = preg_replace_callback($magic_args[0], function($matches) use ($magic_args) + { + return make_clickable_callback($magic_args[1], $matches[1], $matches[2], $matches[3], $magic_args[2]); + }, $text); + } + } + + return $text; } /** -- cgit v1.2.1 From c20f92ba1eb089222bfbe7d7acd5992682a9c936 Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 19 Nov 2012 18:15:59 -0500 Subject: [ticket/11215] Correct paths when path info is used for controller access PHPBB3-11215 --- phpBB/app.php | 1 - phpBB/common.php | 3 +++ phpBB/includes/functions.php | 62 ++++++++++++++++++++++++++++++++++---------- 3 files changed, 52 insertions(+), 14 deletions(-) (limited to 'phpBB') diff --git a/phpBB/app.php b/phpBB/app.php index d93208d585..f1023ff1b5 100644 --- a/phpBB/app.php +++ b/phpBB/app.php @@ -24,7 +24,6 @@ $user->session_begin(); $auth->acl($user->data); $user->setup('app'); -$symfony_request = phpbb_create_symfony_request($request); $http_kernel = $phpbb_container->get('http_kernel'); $response = $http_kernel->handle($symfony_request); $response->send(); diff --git a/phpBB/common.php b/phpBB/common.php index f6f109c3de..236d456eec 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -109,6 +109,9 @@ $db = $phpbb_container->get('dbal.conn'); // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function +// Create a Symfony Request object from our phpbb_request object +$symfony_request = phpbb_create_symfony_request($request); + // Grab global variables, re-cache if necessary $config = $phpbb_container->get('config'); set_config(null, null, null, $config); diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 6a1b3fd4f8..60181c488e 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2413,6 +2413,7 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false) { global $_SID, $_EXTRA_URL, $phpbb_hook; global $phpbb_dispatcher; + global $request; if ($params === '' || (is_array($params) && empty($params))) { @@ -2420,6 +2421,12 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false) $params = false; } + $corrected_root = phpbb_get_web_root_path(phpbb_create_symfony_request($request)); + if ($corrected_root) + { + $url = $corrected_root . substr($url, strlen($phpbb_root_path)); + } + $append_sid_overwrite = false; /** @@ -5209,7 +5216,11 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 // Determine board url - we may need it later $board_url = generate_board_url() . '/'; - $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $phpbb_root_path; + // This path is sent with the base template paths in the assign_vars() + // call below. We need to correct it in case we are accessing from a + // controller because the web paths will be incorrect otherwise. + $corrected_path = phpbb_get_web_root_path(phpbb_create_symfony_request($request)); + $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $corrected_path; // Send a proper content-language to the output $user_lang = $user->lang['USER_LANG']; @@ -5685,6 +5696,16 @@ function phpbb_convert_30_dbms_to_31($dbms) */ function phpbb_create_symfony_request(phpbb_request $request) { + // If we have already gotten it, don't go back through all the trouble of + // creating it again; instead, just return it. This allows multiple calls + // of this method so we don't have to globalize $symfony_request in other + // functions. + static $symfony_request; + if (null !== $symfony_request) + { + return $symfony_request; + } + // This function is meant to sanitize the global input arrays $sanitizer = function(&$value, $key) { $type_cast_helper = new phpbb_request_type_cast_helper(); @@ -5704,21 +5725,36 @@ function phpbb_create_symfony_request(phpbb_request $request) array_walk_recursive($get_parameters, $sanitizer); array_walk_recursive($post_parameters, $sanitizer); - // Until we fix the issue with relative paths, we have to fake path info - // to allow urls like app.php?controller=foo/bar - $controller = $request->variable('controller', ''); - $path_info = '/' . $controller; - $request_uri = $server_parameters['REQUEST_URI']; + $symfony_request = new Request($get_parameters, $post_parameters, array(), $cookie_parameters, $files_parameters, $server_parameters); + return $symfony_request; +} - // Remove the query string from REQUEST_URI - if ($pos = strpos($request_uri, '?')) +/** +* Get a relative root path from the current URL +* +* @param Request $symfony_request Symfony Request object +*/ +function phpbb_get_web_root_path(Request $symfony_request) +{ + static $path; + if (null !== $path) { - $request_uri = substr($request_uri, 0, $pos); + return $path; } - // Add the path info (i.e. controller route) to the REQUEST_URI - $server_parameters['REQUEST_URI'] = $request_uri . $path_info; - $server_parameters['SCRIPT_NAME'] = ''; + $path_info = $symfony_request->getPathInfo(); + if ($path_info == '/') + { + return ''; + } + + $corrections = substr_count($symfony_request->getPathInfo(), '/'); + + $path = ''; + for ($i = 0; $i < $corrections; $i++) + { + $path .= '../'; + } - return new Request($get_parameters, $post_parameters, array(), $cookie_parameters, $files_parameters, $server_parameters); + return $path; } -- cgit v1.2.1 From 0f522ddf5fb6e7d268f9d9cf428b8e3985f374ea Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 19 Nov 2012 19:36:07 -0500 Subject: [ticket/11215] A few minor optimizations for phpbb_get_web_root_path() PHPBB3-11215 --- phpBB/includes/functions.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 60181c488e..213f178694 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5745,16 +5745,12 @@ function phpbb_get_web_root_path(Request $symfony_request) $path_info = $symfony_request->getPathInfo(); if ($path_info == '/') { - return ''; + $path = ''; + return $path; } - $corrections = substr_count($symfony_request->getPathInfo(), '/'); - - $path = ''; - for ($i = 0; $i < $corrections; $i++) - { - $path .= '../'; - } + $corrections = substr_count($path_info, '/'); + $path = str_repeat('../', $corrections); return $path; } -- cgit v1.2.1 From b9c290b5480a958eabeef66d5e9af799f77e4566 Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 20 Nov 2012 16:13:29 -0500 Subject: [ticket/11215] Correct for different URL but same path info When Symfony Request calculates path info, both of the following URLs give "/" as the path info: ./app.php and ./app.php/ This commit ensures that the proper correction is made. PHPBB3-11215 --- phpBB/includes/functions.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 213f178694..331eaf742e 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5743,7 +5743,16 @@ function phpbb_get_web_root_path(Request $symfony_request) } $path_info = $symfony_request->getPathInfo(); - if ($path_info == '/') + + // When no path is given (i.e. REQUEST_URI = "./app.php") path info from + // the Symfony Request object is "/". However, that is the same as when + // the REQUEST_URI is "./app.php/". So we want to correct the path when + // we have a trailing slash in the REQUEST_URI, but not when we don't. + $request_uri = $symfony_request->server->get('REQUEST_URI'); + $trailing_slash = substr($request_uri, -1) === '/'; + + // If pathinfo is / and we do not have a trailing slash in the REQUEST_URI + if (!$trailing_slash && '/' === $path_info) { $path = ''; return $path; -- cgit v1.2.1 From 3a87a6b7007c015cf722b7a4e49f2880ba38f533 Mon Sep 17 00:00:00 2001 From: David King Date: Thu, 11 Jul 2013 20:46:18 -0400 Subject: [ticket/11215] use global PHPBB3-11215 --- phpBB/includes/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 331eaf742e..420a13c200 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2413,7 +2413,7 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false) { global $_SID, $_EXTRA_URL, $phpbb_hook; global $phpbb_dispatcher; - global $request; + global $symfony_request; if ($params === '' || (is_array($params) && empty($params))) { @@ -2421,7 +2421,7 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false) $params = false; } - $corrected_root = phpbb_get_web_root_path(phpbb_create_symfony_request($request)); + $corrected_root = phpbb_get_web_root_path($symfony_request); if ($corrected_root) { $url = $corrected_root . substr($url, strlen($phpbb_root_path)); -- cgit v1.2.1 From 068d35065278bf52e85fcc96b629d25712f19c26 Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 12 Jul 2013 00:03:06 -0400 Subject: [ticket/11215] Don't try to correct paths during tests PHPBB3-11215 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 420a13c200..40583dee54 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2421,7 +2421,7 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false) $params = false; } - $corrected_root = phpbb_get_web_root_path($symfony_request); + $corrected_root = $symfony_request !== null ? phpbb_get_web_root_path($symfony_request) : ''; if ($corrected_root) { $url = $corrected_root . substr($url, strlen($phpbb_root_path)); -- cgit v1.2.1 From fab7f5fdfd2fd8ec50dae52dfde80a706015dd74 Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 13 Jul 2013 11:43:38 -0400 Subject: [ticket/11215] Don't try to use when it isn't there PHPBB3-112515 --- phpBB/includes/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 40583dee54..f637ab2232 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5059,7 +5059,7 @@ function phpbb_build_hidden_fields_for_query_params($request, $exclude = null) function page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum') { global $db, $config, $template, $SID, $_SID, $_EXTRA_URL, $user, $auth, $phpEx, $phpbb_root_path; - global $phpbb_dispatcher, $request, $phpbb_container; + global $phpbb_dispatcher, $request, $phpbb_container, $symfony_request; if (defined('HEADER_INC')) { @@ -5219,7 +5219,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 // This path is sent with the base template paths in the assign_vars() // call below. We need to correct it in case we are accessing from a // controller because the web paths will be incorrect otherwise. - $corrected_path = phpbb_get_web_root_path(phpbb_create_symfony_request($request)); + $corrected_path = $symfony_request !== null ? phpbb_get_web_root_path($symfony_request) : ''; $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $corrected_path; // Send a proper content-language to the output -- cgit v1.2.1 From b81613e5e57fd208e832637b6886abf9ec806c4b Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 14 Jul 2013 12:25:28 -0400 Subject: [ticket/11700] With namespaces interface will no longer be a valid classname PHPBB3-11700 --- phpBB/phpbb/auth/provider/interface.php | 105 ------------ phpBB/phpbb/auth/provider/provider_interface.php | 105 ++++++++++++ phpBB/phpbb/avatar/driver/driver_interface.php | 116 +++++++++++++ phpBB/phpbb/avatar/driver/interface.php | 116 ------------- phpBB/phpbb/cache/driver/driver_interface.php | 144 ++++++++++++++++ phpBB/phpbb/cache/driver/interface.php | 144 ---------------- phpBB/phpbb/db/migration/tool/interface.php | 33 ---- phpBB/phpbb/db/migration/tool/tool_interface.php | 33 ++++ phpBB/phpbb/extension/extension_interface.php | 67 ++++++++ phpBB/phpbb/extension/interface.php | 67 -------- .../groupposition/groupposition_interface.php | 84 +++++++++ phpBB/phpbb/groupposition/interface.php | 84 --------- phpBB/phpbb/log/interface.php | 106 ------------ phpBB/phpbb/log/log_interface.php | 106 ++++++++++++ phpBB/phpbb/notification/method/interface.php | 48 ------ .../phpbb/notification/method/method_interface.php | 48 ++++++ phpBB/phpbb/notification/type/interface.php | 189 --------------------- phpBB/phpbb/notification/type/type_interface.php | 189 +++++++++++++++++++++ phpBB/phpbb/request/interface.php | 139 --------------- phpBB/phpbb/request/request_interface.php | 139 +++++++++++++++ phpBB/phpbb/tree/interface.php | 122 ------------- phpBB/phpbb/tree/tree_interface.php | 122 +++++++++++++ 22 files changed, 1153 insertions(+), 1153 deletions(-) delete mode 100644 phpBB/phpbb/auth/provider/interface.php create mode 100644 phpBB/phpbb/auth/provider/provider_interface.php create mode 100644 phpBB/phpbb/avatar/driver/driver_interface.php delete mode 100644 phpBB/phpbb/avatar/driver/interface.php create mode 100644 phpBB/phpbb/cache/driver/driver_interface.php delete mode 100644 phpBB/phpbb/cache/driver/interface.php delete mode 100644 phpBB/phpbb/db/migration/tool/interface.php create mode 100644 phpBB/phpbb/db/migration/tool/tool_interface.php create mode 100644 phpBB/phpbb/extension/extension_interface.php delete mode 100644 phpBB/phpbb/extension/interface.php create mode 100644 phpBB/phpbb/groupposition/groupposition_interface.php delete mode 100644 phpBB/phpbb/groupposition/interface.php delete mode 100644 phpBB/phpbb/log/interface.php create mode 100644 phpBB/phpbb/log/log_interface.php delete mode 100644 phpBB/phpbb/notification/method/interface.php create mode 100644 phpBB/phpbb/notification/method/method_interface.php delete mode 100644 phpBB/phpbb/notification/type/interface.php create mode 100644 phpBB/phpbb/notification/type/type_interface.php delete mode 100644 phpBB/phpbb/request/interface.php create mode 100644 phpBB/phpbb/request/request_interface.php delete mode 100644 phpBB/phpbb/tree/interface.php create mode 100644 phpBB/phpbb/tree/tree_interface.php (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/interface.php b/phpBB/phpbb/auth/provider/interface.php deleted file mode 100644 index 47043bc107..0000000000 --- a/phpBB/phpbb/auth/provider/interface.php +++ /dev/null @@ -1,105 +0,0 @@ - status constant - * 'error_msg' => string - * 'user_row' => array - * ) - */ - public function login($username, $password); - - /** - * Autologin function - * - * @return array|null containing the user row, empty if no auto login - * should take place, or null if not impletmented. - */ - public function autologin(); - - /** - * This function is used to output any required fields in the authentication - * admin panel. It also defines any required configuration table fields. - * - * @return array|null Returns null if not implemented or an array of the - * configuration fields of the provider. - */ - public function acp(); - - /** - * This function updates the template with variables related to the acp - * options with whatever configuraton values are passed to it as an array. - * It then returns the name of the acp file related to this authentication - * provider. - * @param array $new_config Contains the new configuration values that - * have been set in acp_board. - * @return array|null Returns null if not implemented or an array with - * the template file name and an array of the vars - * that the template needs that must conform to the - * following example: - * array( - * 'TEMPLATE_FILE' => string, - * 'TEMPLATE_VARS' => array(...), - * ) - */ - public function get_acp_template($new_config); - - /** - * Performs additional actions during logout. - * - * @param array $data An array corresponding to - * phpbb_session::data - * @param boolean $new_session True for a new session, false for no new - * session. - */ - public function logout($data, $new_session); - - /** - * The session validation function checks whether the user is still logged - * into phpBB. - * - * @param array $user - * @return boolean true if the given user is authenticated, false if the - * session should be closed, or null if not implemented. - */ - public function validate_session($user); -} diff --git a/phpBB/phpbb/auth/provider/provider_interface.php b/phpBB/phpbb/auth/provider/provider_interface.php new file mode 100644 index 0000000000..baf55c7a86 --- /dev/null +++ b/phpBB/phpbb/auth/provider/provider_interface.php @@ -0,0 +1,105 @@ + status constant + * 'error_msg' => string + * 'user_row' => array + * ) + */ + public function login($username, $password); + + /** + * Autologin function + * + * @return array|null containing the user row, empty if no auto login + * should take place, or null if not impletmented. + */ + public function autologin(); + + /** + * This function is used to output any required fields in the authentication + * admin panel. It also defines any required configuration table fields. + * + * @return array|null Returns null if not implemented or an array of the + * configuration fields of the provider. + */ + public function acp(); + + /** + * This function updates the template with variables related to the acp + * options with whatever configuraton values are passed to it as an array. + * It then returns the name of the acp file related to this authentication + * provider. + * @param array $new_config Contains the new configuration values that + * have been set in acp_board. + * @return array|null Returns null if not implemented or an array with + * the template file name and an array of the vars + * that the template needs that must conform to the + * following example: + * array( + * 'TEMPLATE_FILE' => string, + * 'TEMPLATE_VARS' => array(...), + * ) + */ + public function get_acp_template($new_config); + + /** + * Performs additional actions during logout. + * + * @param array $data An array corresponding to + * phpbb_session::data + * @param boolean $new_session True for a new session, false for no new + * session. + */ + public function logout($data, $new_session); + + /** + * The session validation function checks whether the user is still logged + * into phpBB. + * + * @param array $user + * @return boolean true if the given user is authenticated, false if the + * session should be closed, or null if not implemented. + */ + public function validate_session($user); +} diff --git a/phpBB/phpbb/avatar/driver/driver_interface.php b/phpBB/phpbb/avatar/driver/driver_interface.php new file mode 100644 index 0000000000..0a44a7a1fe --- /dev/null +++ b/phpBB/phpbb/avatar/driver/driver_interface.php @@ -0,0 +1,116 @@ + '', 'width' => 0, 'height' => 0] + */ + public function get_data($row); + + /** + * Returns custom html if it is needed for displaying this avatar + * + * @param phpbb_user $user phpBB user object + * @param array $row User data or group data that has been cleaned with + * phpbb_avatar_manager::clean_row + * @param string $alt Alternate text for avatar image + * + * @return string HTML + */ + public function get_custom_html($user, $row, $alt = ''); + + /** + * Prepare form for changing the settings of this avatar + * + * @param phpbb_request $request Request object + * @param phpbb_template $template Template object + * @param phpbb_user $user User object + * @param array $row User data or group data that has been cleaned with + * phpbb_avatar_manager::clean_row + * @param array &$error Reference to an error array that is filled by this + * function. Key values can either be a string with a language key or + * an array that will be passed to vsprintf() with the language key in + * the first array key. + * + * @return bool True if form has been successfully prepared + */ + public function prepare_form($request, $template, $user, $row, &$error); + + /** + * Prepare form for changing the acp settings of this avatar + * + * @param phpbb_user $user phpBB user object + * + * @return array Array of configuration options as consumed by acp_board. + * The setting for enabling/disabling the avatar will be handled by + * the avatar manager. + */ + public function prepare_form_acp($user); + + /** + * Process form data + * + * @param phpbb_request $request Request object + * @param phpbb_template $template Template object + * @param phpbb_user $user User object + * @param array $row User data or group data that has been cleaned with + * phpbb_avatar_manager::clean_row + * @param array &$error Reference to an error array that is filled by this + * function. Key values can either be a string with a language key or + * an array that will be passed to vsprintf() with the language key in + * the first array key. + * + * @return array Array containing the avatar data as follows: + * ['avatar'], ['avatar_width'], ['avatar_height'] + */ + public function process_form($request, $template, $user, $row, &$error); + + /** + * Delete avatar + * + * @param array $row User data or group data that has been cleaned with + * phpbb_avatar_manager::clean_row + * + * @return bool True if avatar has been deleted or there is no need to delete, + * i.e. when the avatar is not hosted locally. + */ + public function delete($row); + + /** + * Get the avatar driver's template name + * + * @return string Avatar driver's template name + */ + public function get_template_name(); +} diff --git a/phpBB/phpbb/avatar/driver/interface.php b/phpBB/phpbb/avatar/driver/interface.php deleted file mode 100644 index 3d62969aef..0000000000 --- a/phpBB/phpbb/avatar/driver/interface.php +++ /dev/null @@ -1,116 +0,0 @@ - '', 'width' => 0, 'height' => 0] - */ - public function get_data($row); - - /** - * Returns custom html if it is needed for displaying this avatar - * - * @param phpbb_user $user phpBB user object - * @param array $row User data or group data that has been cleaned with - * phpbb_avatar_manager::clean_row - * @param string $alt Alternate text for avatar image - * - * @return string HTML - */ - public function get_custom_html($user, $row, $alt = ''); - - /** - * Prepare form for changing the settings of this avatar - * - * @param phpbb_request $request Request object - * @param phpbb_template $template Template object - * @param phpbb_user $user User object - * @param array $row User data or group data that has been cleaned with - * phpbb_avatar_manager::clean_row - * @param array &$error Reference to an error array that is filled by this - * function. Key values can either be a string with a language key or - * an array that will be passed to vsprintf() with the language key in - * the first array key. - * - * @return bool True if form has been successfully prepared - */ - public function prepare_form($request, $template, $user, $row, &$error); - - /** - * Prepare form for changing the acp settings of this avatar - * - * @param phpbb_user $user phpBB user object - * - * @return array Array of configuration options as consumed by acp_board. - * The setting for enabling/disabling the avatar will be handled by - * the avatar manager. - */ - public function prepare_form_acp($user); - - /** - * Process form data - * - * @param phpbb_request $request Request object - * @param phpbb_template $template Template object - * @param phpbb_user $user User object - * @param array $row User data or group data that has been cleaned with - * phpbb_avatar_manager::clean_row - * @param array &$error Reference to an error array that is filled by this - * function. Key values can either be a string with a language key or - * an array that will be passed to vsprintf() with the language key in - * the first array key. - * - * @return array Array containing the avatar data as follows: - * ['avatar'], ['avatar_width'], ['avatar_height'] - */ - public function process_form($request, $template, $user, $row, &$error); - - /** - * Delete avatar - * - * @param array $row User data or group data that has been cleaned with - * phpbb_avatar_manager::clean_row - * - * @return bool True if avatar has been deleted or there is no need to delete, - * i.e. when the avatar is not hosted locally. - */ - public function delete($row); - - /** - * Get the avatar driver's template name - * - * @return string Avatar driver's template name - */ - public function get_template_name(); -} diff --git a/phpBB/phpbb/cache/driver/driver_interface.php b/phpBB/phpbb/cache/driver/driver_interface.php new file mode 100644 index 0000000000..34028b82e2 --- /dev/null +++ b/phpBB/phpbb/cache/driver/driver_interface.php @@ -0,0 +1,144 @@ + array of users and user types that should not receive notifications from this type because they've already been notified - * e.g.: array(2 => array(''), 3 => array('', 'email'), ...) - * - * @return array - */ - public function find_users_for_notification($type_data, $options); - - /** - * Users needed to query before this notification can be displayed - * - * @return array Array of user_ids - */ - public function users_to_query(); - - /** - * Get the special items to load - * - * @return array Data will be combined sent to load_special() so you can run a single query and get data required for this notification type - */ - public function get_load_special(); - - /** - * Load the special items - * - * @param array $data Data from get_load_special() - * @param array $notifications Array of notifications (key is notification_id, value is the notification objects) - */ - public function load_special($data, $notifications); - - /** - * Get the HTML formatted title of this notification - * - * @return string - */ - public function get_title(); - - /** - * Get the url to this item - * - * @return string URL - */ - public function get_url(); - - /** - * URL to unsubscribe to this notification - * - * @param string|bool $method Method name to unsubscribe from (email|jabber|etc), False to unsubscribe from all notifications for this item - */ - public function get_unsubscribe_url($method); - - /** - * Get the user's avatar (the user who caused the notification typically) - * - * @return string - */ - public function get_avatar(); - - /** - * Prepare to output the notification to the template - */ - public function prepare_for_display(); - - /** - * Get email template - * - * @return string|bool - */ - public function get_email_template(); - - /** - * Get email template variables - * - * @return array - */ - public function get_email_template_variables(); - - /** - * Pre create insert array function - * This allows you to perform certain actions, like run a query - * and load data, before create_insert_array() is run. The data - * returned from this function will be sent to create_insert_array(). - * - * @param array $type_data The type specific data - * @param array $notify_users Notify users list - * Formated from find_users_for_notification() - * @return array Whatever you want to send to create_insert_array(). - */ - public function pre_create_insert_array($type_data, $notify_users); - - /** - * Function for preparing the data for insertion in an SQL query - * (The service handles insertion) - * - * @param array $type_data The type specific data - * @param array $pre_create_data Data from pre_create_insert_array() - * - * @return array Array of data ready to be inserted into the database - */ - public function create_insert_array($type_data, $pre_create_data); - - /** - * Function for preparing the data for update in an SQL query - * (The service handles insertion) - * - * @param array $type_data Data unique to this notification type - * - * @return array Array of data ready to be updated in the database - */ - public function create_update_array($type_data); - - /** - * Mark this item read - * - * @param bool $return True to return a string containing the SQL code to update this item, False to execute it (Default: False) - * @return string - */ - public function mark_read($return); - - /** - * Mark this item unread - * - * @param bool $return True to return a string containing the SQL code to update this item, False to execute it (Default: False) - * @return string - */ - public function mark_unread($return); -} diff --git a/phpBB/phpbb/notification/type/type_interface.php b/phpBB/phpbb/notification/type/type_interface.php new file mode 100644 index 0000000000..f9c65f7286 --- /dev/null +++ b/phpBB/phpbb/notification/type/type_interface.php @@ -0,0 +1,189 @@ + array of users and user types that should not receive notifications from this type because they've already been notified + * e.g.: array(2 => array(''), 3 => array('', 'email'), ...) + * + * @return array + */ + public function find_users_for_notification($type_data, $options); + + /** + * Users needed to query before this notification can be displayed + * + * @return array Array of user_ids + */ + public function users_to_query(); + + /** + * Get the special items to load + * + * @return array Data will be combined sent to load_special() so you can run a single query and get data required for this notification type + */ + public function get_load_special(); + + /** + * Load the special items + * + * @param array $data Data from get_load_special() + * @param array $notifications Array of notifications (key is notification_id, value is the notification objects) + */ + public function load_special($data, $notifications); + + /** + * Get the HTML formatted title of this notification + * + * @return string + */ + public function get_title(); + + /** + * Get the url to this item + * + * @return string URL + */ + public function get_url(); + + /** + * URL to unsubscribe to this notification + * + * @param string|bool $method Method name to unsubscribe from (email|jabber|etc), False to unsubscribe from all notifications for this item + */ + public function get_unsubscribe_url($method); + + /** + * Get the user's avatar (the user who caused the notification typically) + * + * @return string + */ + public function get_avatar(); + + /** + * Prepare to output the notification to the template + */ + public function prepare_for_display(); + + /** + * Get email template + * + * @return string|bool + */ + public function get_email_template(); + + /** + * Get email template variables + * + * @return array + */ + public function get_email_template_variables(); + + /** + * Pre create insert array function + * This allows you to perform certain actions, like run a query + * and load data, before create_insert_array() is run. The data + * returned from this function will be sent to create_insert_array(). + * + * @param array $type_data The type specific data + * @param array $notify_users Notify users list + * Formated from find_users_for_notification() + * @return array Whatever you want to send to create_insert_array(). + */ + public function pre_create_insert_array($type_data, $notify_users); + + /** + * Function for preparing the data for insertion in an SQL query + * (The service handles insertion) + * + * @param array $type_data The type specific data + * @param array $pre_create_data Data from pre_create_insert_array() + * + * @return array Array of data ready to be inserted into the database + */ + public function create_insert_array($type_data, $pre_create_data); + + /** + * Function for preparing the data for update in an SQL query + * (The service handles insertion) + * + * @param array $type_data Data unique to this notification type + * + * @return array Array of data ready to be updated in the database + */ + public function create_update_array($type_data); + + /** + * Mark this item read + * + * @param bool $return True to return a string containing the SQL code to update this item, False to execute it (Default: False) + * @return string + */ + public function mark_read($return); + + /** + * Mark this item unread + * + * @param bool $return True to return a string containing the SQL code to update this item, False to execute it (Default: False) + * @return string + */ + public function mark_unread($return); +} diff --git a/phpBB/phpbb/request/interface.php b/phpBB/phpbb/request/interface.php deleted file mode 100644 index 741db35917..0000000000 --- a/phpBB/phpbb/request/interface.php +++ /dev/null @@ -1,139 +0,0 @@ - "a") - * then specifying array("var", 1) as the name will return "a". - * @param mixed $default A default value that is returned if the variable was not set. - * This function will always return a value of the same type as the default. - * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters - * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks - * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global - * Specifies which super global should be used - * - * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the - * the same as that of $default. If the variable is not set $default is returned. - */ - public function variable($var_name, $default, $multibyte = false, $super_global = phpbb_request_interface::REQUEST); - - /** - * Shortcut method to retrieve SERVER variables. - * - * @param string|array $var_name See phpbb_request_interface::variable - * @param mixed $default See phpbb_request_interface::variable - * - * @return mixed The server variable value. - */ - public function server($var_name, $default = ''); - - /** - * Shortcut method to retrieve the value of client HTTP headers. - * - * @param string|array $header_name The name of the header to retrieve. - * @param mixed $default See phpbb_request_interface::variable - * - * @return mixed The header value. - */ - public function header($var_name, $default = ''); - - /** - * Checks whether a certain variable was sent via POST. - * To make sure that a request was sent using POST you should call this function - * on at least one variable. - * - * @param string $name The name of the form variable which should have a - * _p suffix to indicate the check in the code that creates the form too. - * - * @return bool True if the variable was set in a POST request, false otherwise. - */ - public function is_set_post($name); - - /** - * Checks whether a certain variable is set in one of the super global - * arrays. - * - * @param string $var Name of the variable - * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global - * Specifies the super global which shall be checked - * - * @return bool True if the variable was sent as input - */ - public function is_set($var, $super_global = phpbb_request_interface::REQUEST); - - /** - * Checks whether the current request is an AJAX request (XMLHttpRequest) - * - * @return bool True if the current request is an ajax request - */ - public function is_ajax(); - - /** - * Checks if the current request is happening over HTTPS. - * - * @return bool True if the request is secure. - */ - public function is_secure(); - - /** - * Returns all variable names for a given super global - * - * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global - * The super global from which names shall be taken - * - * @return array All variable names that are set for the super global. - * Pay attention when using these, they are unsanitised! - */ - public function variable_names($super_global = phpbb_request_interface::REQUEST); -} diff --git a/phpBB/phpbb/request/request_interface.php b/phpBB/phpbb/request/request_interface.php new file mode 100644 index 0000000000..482f0f1287 --- /dev/null +++ b/phpBB/phpbb/request/request_interface.php @@ -0,0 +1,139 @@ + "a") + * then specifying array("var", 1) as the name will return "a". + * @param mixed $default A default value that is returned if the variable was not set. + * This function will always return a value of the same type as the default. + * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters + * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks + * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global + * Specifies which super global should be used + * + * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the + * the same as that of $default. If the variable is not set $default is returned. + */ + public function variable($var_name, $default, $multibyte = false, $super_global = phpbb_request_interface::REQUEST); + + /** + * Shortcut method to retrieve SERVER variables. + * + * @param string|array $var_name See phpbb_request_interface::variable + * @param mixed $default See phpbb_request_interface::variable + * + * @return mixed The server variable value. + */ + public function server($var_name, $default = ''); + + /** + * Shortcut method to retrieve the value of client HTTP headers. + * + * @param string|array $header_name The name of the header to retrieve. + * @param mixed $default See phpbb_request_interface::variable + * + * @return mixed The header value. + */ + public function header($var_name, $default = ''); + + /** + * Checks whether a certain variable was sent via POST. + * To make sure that a request was sent using POST you should call this function + * on at least one variable. + * + * @param string $name The name of the form variable which should have a + * _p suffix to indicate the check in the code that creates the form too. + * + * @return bool True if the variable was set in a POST request, false otherwise. + */ + public function is_set_post($name); + + /** + * Checks whether a certain variable is set in one of the super global + * arrays. + * + * @param string $var Name of the variable + * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global + * Specifies the super global which shall be checked + * + * @return bool True if the variable was sent as input + */ + public function is_set($var, $super_global = phpbb_request_interface::REQUEST); + + /** + * Checks whether the current request is an AJAX request (XMLHttpRequest) + * + * @return bool True if the current request is an ajax request + */ + public function is_ajax(); + + /** + * Checks if the current request is happening over HTTPS. + * + * @return bool True if the request is secure. + */ + public function is_secure(); + + /** + * Returns all variable names for a given super global + * + * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global + * The super global from which names shall be taken + * + * @return array All variable names that are set for the super global. + * Pay attention when using these, they are unsanitised! + */ + public function variable_names($super_global = phpbb_request_interface::REQUEST); +} diff --git a/phpBB/phpbb/tree/interface.php b/phpBB/phpbb/tree/interface.php deleted file mode 100644 index cc8aab2115..0000000000 --- a/phpBB/phpbb/tree/interface.php +++ /dev/null @@ -1,122 +0,0 @@ - down, > 0 => up - * @return bool True if the item was moved - */ - public function move($item_id, $delta); - - /** - * Move an item down by 1 - * - * @param int $item_id The item to be moved - * @return bool True if the item was moved - */ - public function move_down($item_id); - - /** - * Move an item up by 1 - * - * @param int $item_id The item to be moved - * @return bool True if the item was moved - */ - public function move_up($item_id); - - /** - * Moves all children of one item to another item - * - * If the new parent already has children, the new children are appended - * to the list. - * - * @param int $current_parent_id The current parent item - * @param int $new_parent_id The new parent item - * @return bool True if any items where moved - */ - public function move_children($current_parent_id, $new_parent_id); - - /** - * Change parent item - * - * Moves the item to the bottom of the new parent's list of children - * - * @param int $item_id The item to be moved - * @param int $new_parent_id The new parent item - * @return bool True if the parent was set successfully - */ - public function change_parent($item_id, $new_parent_id); - - /** - * Get all items that are either ancestors or descendants of the item - * - * @param int $item_id Id of the item to retrieve the ancestors/descendants from - * @param bool $order_asc Order the items ascendingly (most outer ancestor first) - * @param bool $include_item Should the item matching the given item id be included in the list as well - * @return array Array of items (containing all columns from the item table) - * ID => Item data - */ - public function get_path_and_subtree_data($item_id, $order_asc, $include_item); - - /** - * Get all of the item's ancestors - * - * @param int $item_id Id of the item to retrieve the ancestors from - * @param bool $order_asc Order the items ascendingly (most outer ancestor first) - * @param bool $include_item Should the item matching the given item id be included in the list as well - * @return array Array of items (containing all columns from the item table) - * ID => Item data - */ - public function get_path_data($item_id, $order_asc, $include_item); - - /** - * Get all of the item's descendants - * - * @param int $item_id Id of the item to retrieve the descendants from - * @param bool $order_asc Order the items ascendingly - * @param bool $include_item Should the item matching the given item id be included in the list as well - * @return array Array of items (containing all columns from the item table) - * ID => Item data - */ - public function get_subtree_data($item_id, $order_asc, $include_item); -} diff --git a/phpBB/phpbb/tree/tree_interface.php b/phpBB/phpbb/tree/tree_interface.php new file mode 100644 index 0000000000..80d3c4377c --- /dev/null +++ b/phpBB/phpbb/tree/tree_interface.php @@ -0,0 +1,122 @@ + down, > 0 => up + * @return bool True if the item was moved + */ + public function move($item_id, $delta); + + /** + * Move an item down by 1 + * + * @param int $item_id The item to be moved + * @return bool True if the item was moved + */ + public function move_down($item_id); + + /** + * Move an item up by 1 + * + * @param int $item_id The item to be moved + * @return bool True if the item was moved + */ + public function move_up($item_id); + + /** + * Moves all children of one item to another item + * + * If the new parent already has children, the new children are appended + * to the list. + * + * @param int $current_parent_id The current parent item + * @param int $new_parent_id The new parent item + * @return bool True if any items where moved + */ + public function move_children($current_parent_id, $new_parent_id); + + /** + * Change parent item + * + * Moves the item to the bottom of the new parent's list of children + * + * @param int $item_id The item to be moved + * @param int $new_parent_id The new parent item + * @return bool True if the parent was set successfully + */ + public function change_parent($item_id, $new_parent_id); + + /** + * Get all items that are either ancestors or descendants of the item + * + * @param int $item_id Id of the item to retrieve the ancestors/descendants from + * @param bool $order_asc Order the items ascendingly (most outer ancestor first) + * @param bool $include_item Should the item matching the given item id be included in the list as well + * @return array Array of items (containing all columns from the item table) + * ID => Item data + */ + public function get_path_and_subtree_data($item_id, $order_asc, $include_item); + + /** + * Get all of the item's ancestors + * + * @param int $item_id Id of the item to retrieve the ancestors from + * @param bool $order_asc Order the items ascendingly (most outer ancestor first) + * @param bool $include_item Should the item matching the given item id be included in the list as well + * @return array Array of items (containing all columns from the item table) + * ID => Item data + */ + public function get_path_data($item_id, $order_asc, $include_item); + + /** + * Get all of the item's descendants + * + * @param int $item_id Id of the item to retrieve the descendants from + * @param bool $order_asc Order the items ascendingly + * @param bool $include_item Should the item matching the given item id be included in the list as well + * @return array Array of items (containing all columns from the item table) + * ID => Item data + */ + public function get_subtree_data($item_id, $order_asc, $include_item); +} -- cgit v1.2.1 From da2752e4004b296ae5acdd08b7c0a758d8f61e9d Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 14 Jul 2013 13:30:52 -0400 Subject: [ticket/11700] Modify all code to use the new interface names PHPBB3-11700 --- phpBB/includes/acp/acp_attachments.php | 2 +- phpBB/includes/acp/acp_board.php | 2 +- phpBB/includes/acp/acp_icons.php | 4 +- phpBB/includes/acp/acp_language.php | 4 +- phpBB/includes/acp/acp_logs.php | 4 +- phpBB/includes/acp/acp_permissions.php | 8 ++-- phpBB/includes/acp/acp_profile.php | 4 +- phpBB/includes/functions.php | 44 ++++++++--------- phpBB/includes/functions_admin.php | 2 +- phpBB/includes/functions_display.php | 10 ++-- phpBB/includes/functions_upload.php | 2 +- phpBB/includes/mcp/mcp_forum.php | 4 +- phpBB/includes/mcp/mcp_main.php | 8 ++-- phpBB/includes/mcp/mcp_queue.php | 6 +-- phpBB/includes/message_parser.php | 2 +- phpBB/includes/ucp/ucp_groups.php | 4 +- phpBB/includes/ucp/ucp_main.php | 2 +- phpBB/includes/ucp/ucp_profile.php | 6 +-- phpBB/install/install_update.php | 4 +- phpBB/mcp.php | 2 +- phpBB/memberlist.php | 2 +- phpBB/phpbb/auth/provider/apache.php | 8 ++-- phpBB/phpbb/auth/provider/base.php | 2 +- phpBB/phpbb/avatar/driver/driver.php | 8 ++-- phpBB/phpbb/cache/driver/base.php | 2 +- phpBB/phpbb/cache/service.php | 12 ++--- phpBB/phpbb/class_loader.php | 8 ++-- phpBB/phpbb/config/db.php | 6 +-- phpBB/phpbb/cron/task/core/prune_forum.php | 6 +-- phpBB/phpbb/cron/task/core/tidy_cache.php | 4 +- phpBB/phpbb/cron/task/parametrized.php | 6 +-- phpBB/phpbb/db/migration/tool/config.php | 2 +- phpBB/phpbb/db/migration/tool/module.php | 2 +- phpBB/phpbb/db/migration/tool/permission.php | 2 +- phpBB/phpbb/extension/base.php | 2 +- phpBB/phpbb/extension/finder.php | 4 +- phpBB/phpbb/extension/manager.php | 6 +-- phpBB/phpbb/feed/base.php | 6 +-- phpBB/phpbb/groupposition/legend.php | 2 +- phpBB/phpbb/groupposition/teampage.php | 8 ++-- phpBB/phpbb/hook/finder.php | 4 +- phpBB/phpbb/log/log.php | 2 +- phpBB/phpbb/notification/manager.php | 4 +- phpBB/phpbb/notification/method/base.php | 12 ++--- .../phpbb/notification/method/method_interface.php | 4 +- phpBB/phpbb/notification/type/base.php | 8 ++-- phpBB/phpbb/request/deactivated_super_global.php | 10 ++-- phpBB/phpbb/request/request.php | 56 +++++++++++----------- phpBB/phpbb/request/request_interface.php | 22 ++++----- phpBB/phpbb/session.php | 6 +-- phpBB/phpbb/tree/nestedset.php | 2 +- phpBB/posting.php | 2 +- phpBB/search.php | 2 +- phpBB/ucp.php | 4 +- phpBB/viewtopic.php | 4 +- 55 files changed, 182 insertions(+), 182 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php index d0e8ff3882..f7b3a166dd 100644 --- a/phpBB/includes/acp/acp_attachments.php +++ b/phpBB/includes/acp/acp_attachments.php @@ -1472,7 +1472,7 @@ class acp_attachments $ip_list = array_unique(explode("\n", $ips)); $ip_list_log = implode(', ', $ip_list); - $ip_exclude = (int) $request->variable('ipexclude', false, false, phpbb_request_interface::POST); + $ip_exclude = (int) $request->variable('ipexclude', false, false, phpbb_request_request_interface::POST); $iplist = array(); $hostlist = array(); diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 12e2a1bf72..2a0d517307 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -679,7 +679,7 @@ class acp_board foreach ($auth_providers as $key => $value) { - if (!($value instanceof phpbb_auth_provider_interface)) + if (!($value instanceof phpbb_auth_provider_provider_interface)) { continue; } diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index db4b4263b0..f72ac82f6a 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -338,7 +338,7 @@ class acp_icons $image_display_on_posting = (isset($_POST['display_on_posting'])) ? request_var('display_on_posting', array('' => 0)) : array(); // Ok, add the relevant bits if we are adding new codes to existing emoticons... - if ($request->variable('add_additional_code', false, false, phpbb_request_interface::POST)) + if ($request->variable('add_additional_code', false, false, phpbb_request_request_interface::POST)) { $add_image = request_var('add_image', ''); $add_code = utf8_normalize_nfc(request_var('add_code', '', true)); @@ -354,7 +354,7 @@ class acp_icons $image_width[$add_image] = request_var('add_width', 0); $image_height[$add_image] = request_var('add_height', 0); - if ($request->variable('add_display_on_posting', false, false, phpbb_request_interface::POST)) + if ($request->variable('add_display_on_posting', false, false, phpbb_request_request_interface::POST)) { $image_display_on_posting[$add_image] = 1; } diff --git a/phpBB/includes/acp/acp_language.php b/phpBB/includes/acp/acp_language.php index 2be1ccfc41..9d3532244f 100644 --- a/phpBB/includes/acp/acp_language.php +++ b/phpBB/includes/acp/acp_language.php @@ -161,7 +161,7 @@ class acp_language 'method' => $method) ); - $hidden_data .= build_hidden_fields(array('entry' => $request->variable('entry', $request_default, true, phpbb_request_interface::POST))); + $hidden_data .= build_hidden_fields(array('entry' => $request->variable('entry', $request_default, true, phpbb_request_request_interface::POST))); $template->assign_vars(array( 'S_UPLOAD' => true, @@ -218,7 +218,7 @@ class acp_language trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING); } - $entry_value = $request->variable('entry', $request_default, true, phpbb_request_interface::POST); + $entry_value = $request->variable('entry', $request_default, true, phpbb_request_request_interface::POST); if (!$lang_id || !$entry_value) { diff --git a/phpBB/includes/acp/acp_logs.php b/phpBB/includes/acp/acp_logs.php index d86521532c..2120f67675 100644 --- a/phpBB/includes/acp/acp_logs.php +++ b/phpBB/includes/acp/acp_logs.php @@ -35,8 +35,8 @@ class acp_logs $forum_id = request_var('f', 0); $topic_id = request_var('t', 0); $start = request_var('start', 0); - $deletemark = $request->variable('delmarked', false, false, phpbb_request_interface::POST); - $deleteall = $request->variable('delall', false, false, phpbb_request_interface::POST); + $deletemark = $request->variable('delmarked', false, false, phpbb_request_request_interface::POST); + $deleteall = $request->variable('delall', false, false, phpbb_request_request_interface::POST); $marked = request_var('mark', array(0)); // Sort keys diff --git a/phpBB/includes/acp/acp_permissions.php b/phpBB/includes/acp/acp_permissions.php index a64765f4f5..57e14c4787 100644 --- a/phpBB/includes/acp/acp_permissions.php +++ b/phpBB/includes/acp/acp_permissions.php @@ -676,7 +676,7 @@ class acp_permissions list($ug_id, ) = each($psubmit); list($forum_id, ) = each($psubmit[$ug_id]); - $settings = $request->variable('setting', array(0 => array(0 => array('' => 0))), false, phpbb_request_interface::POST); + $settings = $request->variable('setting', array(0 => array(0 => array('' => 0))), false, phpbb_request_request_interface::POST); if (empty($settings) || empty($settings[$ug_id]) || empty($settings[$ug_id][$forum_id])) { trigger_error('WRONG_PERMISSION_SETTING_FORMAT', E_USER_WARNING); @@ -685,7 +685,7 @@ class acp_permissions $auth_settings = $settings[$ug_id][$forum_id]; // Do we have a role we want to set? - $roles = $request->variable('role', array(0 => array(0 => 0)), false, phpbb_request_interface::POST); + $roles = $request->variable('role', array(0 => array(0 => 0)), false, phpbb_request_request_interface::POST); $assigned_role = (isset($roles[$ug_id][$forum_id])) ? (int) $roles[$ug_id][$forum_id] : 0; // Do the admin want to set these permissions to other items too? @@ -757,8 +757,8 @@ class acp_permissions trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); } - $auth_settings = $request->variable('setting', array(0 => array(0 => array('' => 0))), false, phpbb_request_interface::POST); - $auth_roles = $request->variable('role', array(0 => array(0 => 0)), false, phpbb_request_interface::POST); + $auth_settings = $request->variable('setting', array(0 => array(0 => array('' => 0))), false, phpbb_request_request_interface::POST); + $auth_roles = $request->variable('role', array(0 => array(0 => 0)), false, phpbb_request_request_interface::POST); $ug_ids = $forum_ids = array(); // We need to go through the auth settings diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index 849160f1fa..09a88d4311 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -510,7 +510,7 @@ class acp_profile $cp->vars['field_default_value_month'] = $now['mon']; $cp->vars['field_default_value_year'] = $now['year']; $var = 'now'; - $request->overwrite('field_default_value', $var, phpbb_request_interface::POST); + $request->overwrite('field_default_value', $var, phpbb_request_request_interface::POST); } else { @@ -520,7 +520,7 @@ class acp_profile $cp->vars['field_default_value_month'] = request_var('field_default_value_month', 0); $cp->vars['field_default_value_year'] = request_var('field_default_value_year', 0); $var = sprintf('%2d-%2d-%4d', $cp->vars['field_default_value_day'], $cp->vars['field_default_value_month'], $cp->vars['field_default_value_year']); - $request->overwrite('field_default_value', $var, phpbb_request_interface::POST); + $request->overwrite('field_default_value', $var, phpbb_request_request_interface::POST); } else { diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 49f2e469bc..174ba712ba 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -32,7 +32,7 @@ function set_var(&$result, $var, $type, $multibyte = false) /** * Wrapper function of phpbb_request::variable which exists for backwards compatability. -* See {@link phpbb_request_interface::variable phpbb_request_interface::variable} for +* See {@link phpbb_request_request_interface::variable phpbb_request_request_interface::variable} for * documentation of this function's use. * * @deprecated @@ -40,20 +40,20 @@ function set_var(&$result, $var, $type, $multibyte = false) * If the value is an array this may be an array of indizes which will give * direct access to a value at any depth. E.g. if the value of "var" is array(1 => "a") * then specifying array("var", 1) as the name will return "a". -* If you pass an instance of {@link phpbb_request_interface phpbb_request_interface} +* If you pass an instance of {@link phpbb_request_request_interface phpbb_request_interface} * as this parameter it will overwrite the current request class instance. If you do * not do so, it will create its own instance (but leave superglobals enabled). * @param mixed $default A default value that is returned if the variable was not set. * This function will always return a value of the same type as the default. * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks -* @param bool $cookie This param is mapped to phpbb_request_interface::COOKIE as the last param for -* phpbb_request_interface::variable for backwards compatability reasons. -* @param phpbb_request_interface|null|false If an instance of phpbb_request_interface is given the instance is stored in +* @param bool $cookie This param is mapped to phpbb_request_request_interface::COOKIE as the last param for +* phpbb_request_request_interface::variable for backwards compatability reasons. +* @param phpbb_request_request_interface|null|false If an instance of phpbb_request_request_interface is given the instance is stored in * a static variable and used for all further calls where this parameters is null. Until * the function is called with an instance it automatically creates a new phpbb_request * instance on every call. By passing false this per-call instantiation can be restored -* after having passed in a phpbb_request_interface instance. +* after having passed in a phpbb_request_request_interface instance. * * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the * the same as that of $default. If the variable is not set $default is returned. @@ -64,7 +64,7 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false, $ // the only real code is the function call which maps this function to a method. static $static_request = null; - if ($request instanceof phpbb_request_interface) + if ($request instanceof phpbb_request_request_interface) { $static_request = $request; @@ -93,7 +93,7 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false, $ $tmp_request = new phpbb_request(new phpbb_request_type_cast_helper(), false); } - return $tmp_request->variable($var_name, $default, $multibyte, ($cookie) ? phpbb_request_interface::COOKIE : phpbb_request_interface::REQUEST); + return $tmp_request->variable($var_name, $default, $multibyte, ($cookie) ? phpbb_request_request_interface::COOKIE : phpbb_request_request_interface::REQUEST); } /** @@ -1391,7 +1391,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ } else if ($config['load_anon_lastread'] || $user->data['is_registered']) { - $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(); unset($tracking_topics['tf']); @@ -1400,7 +1400,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ $tracking_topics['l'] = base_convert($post_time - $config['board_startdate'], 10, 36); $user->set_cookie('track', tracking_serialize($tracking_topics), $post_time + 31536000); - $request->overwrite($config['cookie_name'] . '_track', tracking_serialize($tracking_topics), phpbb_request_interface::COOKIE); + $request->overwrite($config['cookie_name'] . '_track', tracking_serialize($tracking_topics), phpbb_request_request_interface::COOKIE); unset($tracking_topics); @@ -1503,7 +1503,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ } else if ($config['load_anon_lastread'] || $user->data['is_registered']) { - $tracking = $request->variable($config['cookie_name'] . '_track', '', true, phpbb_request_interface::COOKIE); + $tracking = $request->variable($config['cookie_name'] . '_track', '', true, phpbb_request_request_interface::COOKIE); $tracking = ($tracking) ? tracking_unserialize($tracking) : array(); foreach ($forum_id as $f_id) @@ -1534,7 +1534,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ } $user->set_cookie('track', tracking_serialize($tracking), $post_time + 31536000); - $request->overwrite($config['cookie_name'] . '_track', tracking_serialize($tracking), phpbb_request_interface::COOKIE); + $request->overwrite($config['cookie_name'] . '_track', tracking_serialize($tracking), phpbb_request_request_interface::COOKIE); unset($tracking); } @@ -1591,7 +1591,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ } else if ($config['load_anon_lastread'] || $user->data['is_registered']) { - $tracking = $request->variable($config['cookie_name'] . '_track', '', true, phpbb_request_interface::COOKIE); + $tracking = $request->variable($config['cookie_name'] . '_track', '', true, phpbb_request_request_interface::COOKIE); $tracking = ($tracking) ? tracking_unserialize($tracking) : array(); $topic_id36 = base_convert($topic_id, 10, 36); @@ -1605,7 +1605,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ // If the cookie grows larger than 10000 characters we will remove the smallest value // This can result in old topics being unread - but most of the time it should be accurate... - if (strlen($request->variable($config['cookie_name'] . '_track', '', true, phpbb_request_interface::COOKIE)) > 10000) + if (strlen($request->variable($config['cookie_name'] . '_track', '', true, phpbb_request_request_interface::COOKIE)) > 10000) { //echo 'Cookie grown too large' . print_r($tracking, true); @@ -1650,7 +1650,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ } $user->set_cookie('track', tracking_serialize($tracking), $post_time + 31536000); - $request->overwrite($config['cookie_name'] . '_track', tracking_serialize($tracking), phpbb_request_interface::COOKIE); + $request->overwrite($config['cookie_name'] . '_track', tracking_serialize($tracking), phpbb_request_request_interface::COOKIE); } return; @@ -1788,7 +1788,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis if (!isset($tracking_topics) || !sizeof($tracking_topics)) { - $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(); } @@ -1985,7 +1985,7 @@ function update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_ti } else if ($config['load_anon_lastread'] || $user->data['is_registered']) { - $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(); if (!$user->data['is_registered']) @@ -3094,7 +3094,7 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo return false; } - $confirm = ($user->lang['YES'] === $request->variable('confirm', '', true, phpbb_request_interface::POST)); + $confirm = ($user->lang['YES'] === $request->variable('confirm', '', true, phpbb_request_request_interface::POST)); if ($check && $confirm) { @@ -4896,7 +4896,7 @@ function phpbb_http_login($param) $username = null; foreach ($username_keys as $k) { - if ($request->is_set($k, phpbb_request_interface::SERVER)) + if ($request->is_set($k, phpbb_request_request_interface::SERVER)) { $username = htmlspecialchars_decode($request->server($k)); break; @@ -4906,7 +4906,7 @@ function phpbb_http_login($param) $password = null; foreach ($password_keys as $k) { - if ($request->is_set($k, phpbb_request_interface::SERVER)) + if ($request->is_set($k, phpbb_request_request_interface::SERVER)) { $password = htmlspecialchars_decode($request->server($k)); break; @@ -5013,7 +5013,7 @@ function phpbb_quoteattr($data, $entities = null) */ function phpbb_build_hidden_fields_for_query_params($request, $exclude = null) { - $names = $request->variable_names(phpbb_request_interface::GET); + $names = $request->variable_names(phpbb_request_request_interface::GET); $hidden = ''; foreach ($names as $name) { @@ -5035,7 +5035,7 @@ function phpbb_build_hidden_fields_for_query_params($request, $exclude = null) // here. To avoid exposing cookies, skip variables that are // overwritten somewhere other than GET entirely. $value = $request->variable($name, '', true); - $get_value = $request->variable($name, '', true, phpbb_request_interface::GET); + $get_value = $request->variable($name, '', true, phpbb_request_request_interface::GET); if ($value === $get_value) { $escaped_value = phpbb_quoteattr($value); diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index fc29492ac1..fada0b52be 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2349,7 +2349,7 @@ function auto_prune($forum_id, $prune_mode, $prune_flags, $prune_days, $prune_fr * must be carried through for the moderators table. * * @param phpbb_db_driver $db Database connection -* @param phpbb_cache_driver_interface Cache driver +* @param phpbb_cache_driver_driver_interface Cache driver * @param phpbb_auth $auth Authentication object * @return null */ diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index b1dac64bec..f05c88419a 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -104,7 +104,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod } else if ($config['load_anon_lastread'] || $user->data['is_registered']) { - $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(); if (!$user->data['is_registered']) @@ -1164,7 +1164,7 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id, if ($token && check_link_hash($token, "{$mode}_$match_id") || confirm_box(true)) { - if ($uid != $user_id || $request->variable('unwatch', '', false, phpbb_request_interface::GET) != $mode) + if ($uid != $user_id || $request->variable('unwatch', '', false, phpbb_request_request_interface::GET) != $mode) { $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); $message = $user->lang['ERR_UNWATCHING'] . '

' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '', ''); @@ -1229,7 +1229,7 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id, if ($token && check_link_hash($token, "{$mode}_$match_id") || confirm_box(true)) { - if ($uid != $user_id || $request->variable('watch', '', false, phpbb_request_interface::GET) != $mode) + if ($uid != $user_id || $request->variable('watch', '', false, phpbb_request_request_interface::GET) != $mode) { $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); $message = $user->lang['ERR_WATCHING'] . '

' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '', ''); @@ -1272,8 +1272,8 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id, } else { - if ((isset($_GET['unwatch']) && $request->variable('unwatch', '', false, phpbb_request_interface::GET) == $mode) || - (isset($_GET['watch']) && $request->variable('watch', '', false, phpbb_request_interface::GET) == $mode)) + if ((isset($_GET['unwatch']) && $request->variable('unwatch', '', false, phpbb_request_request_interface::GET) == $mode) || + (isset($_GET['watch']) && $request->variable('watch', '', false, phpbb_request_request_interface::GET) == $mode)) { login_box(); } diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php index 4f31a85e83..6261231c09 100644 --- a/phpBB/includes/functions_upload.php +++ b/phpBB/includes/functions_upload.php @@ -713,7 +713,7 @@ class fileupload } $this->common_checks($file); - $request->overwrite('local', $upload, phpbb_request_interface::FILES); + $request->overwrite('local', $upload, phpbb_request_request_interface::FILES); return $file; } diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index 841a0afddb..5439aba232 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -36,8 +36,8 @@ function mcp_forum_view($id, $mode, $action, $forum_info) // Fixes a "bug" that makes forum_view use the same ordering as topic_view $request->overwrite('sk', null); $request->overwrite('sd', null); - $request->overwrite('sk', null, phpbb_request_interface::POST); - $request->overwrite('sd', null, phpbb_request_interface::POST); + $request->overwrite('sk', null, phpbb_request_request_interface::POST); + $request->overwrite('sd', null, phpbb_request_request_interface::POST); } $forum_id = $forum_info['forum_id']; diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index 275edbe55a..989419cc49 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -462,7 +462,7 @@ function mcp_move_topic($topic_ids) if (!$to_forum_id || $additional_msg) { - $request->overwrite('confirm', null, phpbb_request_interface::POST); + $request->overwrite('confirm', null, phpbb_request_request_interface::POST); $request->overwrite('confirm_key', null); } @@ -694,7 +694,7 @@ function mcp_restore_topic($topic_ids) } $topic_id = $request->variable('t', 0); - if (!$request->is_set('quickmod', phpbb_request_interface::REQUEST)) + if (!$request->is_set('quickmod', phpbb_request_request_interface::REQUEST)) { $redirect = $request->variable('redirect', "index.$phpEx"); $redirect = reapply_sid($redirect); @@ -823,7 +823,7 @@ function mcp_delete_topic($topic_ids, $is_soft = false, $soft_delete_reason = '' } $topic_id = $request->variable('t', 0); - if (!$request->is_set('quickmod', phpbb_request_interface::REQUEST)) + if (!$request->is_set('quickmod', phpbb_request_request_interface::REQUEST)) { $redirect = $request->variable('redirect', "index.$phpEx"); $redirect = reapply_sid($redirect); @@ -1136,7 +1136,7 @@ function mcp_fork_topic($topic_ids) if ($additional_msg) { - $request->overwrite('confirm', null, phpbb_request_interface::POST); + $request->overwrite('confirm', null, phpbb_request_request_interface::POST); $request->overwrite('confirm_key', null); } diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 8a9390212f..aa0725efff 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -946,9 +946,9 @@ class mcp_queue { $additional_msg = $user->lang['NO_REASON_DISAPPROVAL']; - $request->overwrite('confirm', null, phpbb_request_interface::POST); - $request->overwrite('confirm_key', null, phpbb_request_interface::POST); - $request->overwrite('confirm_key', null, phpbb_request_interface::REQUEST); + $request->overwrite('confirm', null, phpbb_request_request_interface::POST); + $request->overwrite('confirm_key', null, phpbb_request_request_interface::POST); + $request->overwrite('confirm_key', null, phpbb_request_request_interface::REQUEST); } else { diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 44960dd78d..6971b786fb 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -1545,7 +1545,7 @@ class parse_message extends bbcode_firstpass global $request; $this->filename_data['filecomment'] = utf8_normalize_nfc(request_var('filecomment', '', true)); - $attachment_data = $request->variable('attachment_data', array(0 => array('' => '')), true, phpbb_request_interface::POST); + $attachment_data = $request->variable('attachment_data', array(0 => array('' => '')), true, phpbb_request_request_interface::POST); $this->attachment_data = array(); $check_user_id = ($check_user_id === false) ? $user->data['user_id'] : $check_user_id; diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index 8620e33e47..03d3de3337 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -34,8 +34,8 @@ class ucp_groups $return_page = '

' . sprintf($user->lang['RETURN_PAGE'], '', ''); $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) diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php index 615b567134..c2b48e7bc6 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_profile.php b/phpBB/includes/ucp/ucp_profile.php index 55df5f610c..ff1e3d1a95 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 = ''; diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index df9b6c1c7e..2d165b551a 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -248,7 +248,7 @@ class install_update extends module $this->include_file('includes/diff/renderer.' . $phpEx); // Make sure we stay at the file check if checking the files again - if ($request->variable('check_again', false, false, phpbb_request_interface::POST)) + if ($request->variable('check_again', false, false, phpbb_request_request_interface::POST)) { $sub = $this->p_master->sub = 'file_check'; } @@ -355,7 +355,7 @@ class install_update extends module $action = request_var('action', ''); // We are directly within an update. To make sure our update list is correct we check its status. - $update_list = ($request->variable('check_again', false, false, phpbb_request_interface::POST)) ? false : $cache->get('_update_list'); + $update_list = ($request->variable('check_again', false, false, phpbb_request_request_interface::POST)) ? false : $cache->get('_update_list'); $modified = ($update_list !== false) ? @filemtime($cache->get_driver()->cache_dir . 'data_update_list.' . $phpEx) : 0; // Make sure the list is up-to-date diff --git a/phpBB/mcp.php b/phpBB/mcp.php index 5beea45c7d..1ab9ec2fb6 100644 --- a/phpBB/mcp.php +++ b/phpBB/mcp.php @@ -49,7 +49,7 @@ $action = request_var('action', ''); $action_ary = request_var('action', array('' => 0)); $forum_action = request_var('forum_action', ''); -if ($forum_action !== '' && $request->variable('sort', false, false, phpbb_request_interface::POST)) +if ($forum_action !== '' && $request->variable('sort', false, false, phpbb_request_request_interface::POST)) { $action = $forum_action; } diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 46136dbdd4..e4cd5e7daa 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1058,7 +1058,7 @@ switch ($mode) // We validate form and field here, only id/class allowed $form = (!preg_match('/^[a-z0-9_-]+$/i', $form)) ? '' : $form; $field = (!preg_match('/^[a-z0-9_-]+$/i', $field)) ? '' : $field; - if ((($mode == '' || $mode == 'searchuser') || sizeof(array_intersect($request->variable_names(phpbb_request_interface::GET), $search_params)) > 0) && ($config['load_search'] || $auth->acl_get('a_'))) + if ((($mode == '' || $mode == 'searchuser') || sizeof(array_intersect($request->variable_names(phpbb_request_request_interface::GET), $search_params)) > 0) && ($config['load_search'] || $auth->acl_get('a_'))) { $username = request_var('username', '', true); $email = strtolower(request_var('email', '')); diff --git a/phpBB/phpbb/auth/provider/apache.php b/phpBB/phpbb/auth/provider/apache.php index 2e80436f78..a7148c634a 100644 --- a/phpBB/phpbb/auth/provider/apache.php +++ b/phpBB/phpbb/auth/provider/apache.php @@ -47,7 +47,7 @@ class phpbb_auth_provider_apache extends phpbb_auth_provider_base */ public function init() { - if (!$this->request->is_set('PHP_AUTH_USER', phpbb_request_interface::SERVER) || $this->user->data['username'] !== htmlspecialchars_decode($this->request->server('PHP_AUTH_USER'))) + if (!$this->request->is_set('PHP_AUTH_USER', phpbb_request_request_interface::SERVER) || $this->user->data['username'] !== htmlspecialchars_decode($this->request->server('PHP_AUTH_USER'))) { return $this->user->lang['APACHE_SETUP_BEFORE_USE']; } @@ -78,7 +78,7 @@ class phpbb_auth_provider_apache extends phpbb_auth_provider_base ); } - if (!$this->request->is_set('PHP_AUTH_USER', phpbb_request_interface::SERVER)) + if (!$this->request->is_set('PHP_AUTH_USER', phpbb_request_request_interface::SERVER)) { return array( 'status' => LOGIN_ERROR_EXTERNAL_AUTH, @@ -149,7 +149,7 @@ class phpbb_auth_provider_apache extends phpbb_auth_provider_base */ public function autologin() { - if (!$this->request->is_set('PHP_AUTH_USER', phpbb_request_interface::SERVER)) + if (!$this->request->is_set('PHP_AUTH_USER', phpbb_request_request_interface::SERVER)) { return array(); } @@ -241,7 +241,7 @@ class phpbb_auth_provider_apache extends phpbb_auth_provider_base public function validate_session($user) { // Check if PHP_AUTH_USER is set and handle this case - if ($this->request->is_set('PHP_AUTH_USER', phpbb_request_interface::SERVER)) + if ($this->request->is_set('PHP_AUTH_USER', phpbb_request_request_interface::SERVER)) { $php_auth_user = $this->request->server('PHP_AUTH_USER'); diff --git a/phpBB/phpbb/auth/provider/base.php b/phpBB/phpbb/auth/provider/base.php index 7eaf8bb2d3..626ad8478f 100644 --- a/phpBB/phpbb/auth/provider/base.php +++ b/phpBB/phpbb/auth/provider/base.php @@ -20,7 +20,7 @@ if (!defined('IN_PHPBB')) * * @package auth */ -abstract class phpbb_auth_provider_base implements phpbb_auth_provider_interface +abstract class phpbb_auth_provider_base implements phpbb_auth_provider_provider_interface { /** * {@inheritdoc} diff --git a/phpBB/phpbb/avatar/driver/driver.php b/phpBB/phpbb/avatar/driver/driver.php index 29c58d4e62..a125759e3f 100644 --- a/phpBB/phpbb/avatar/driver/driver.php +++ b/phpBB/phpbb/avatar/driver/driver.php @@ -19,7 +19,7 @@ if (!defined('IN_PHPBB')) * Base class for avatar drivers * @package phpBB3 */ -abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface +abstract class phpbb_avatar_driver implements phpbb_avatar_driver_driver_interface { /** * Avatar driver name @@ -47,7 +47,7 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface /** * Cache driver - * @var phpbb_cache_driver_interface + * @var phpbb_cache_driver_driver_interface */ protected $cache; @@ -73,9 +73,9 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface * @param phpbb_request $request Request object * @param string $phpbb_root_path Path to the phpBB root * @param string $php_ext PHP file extension - * @param phpbb_cache_driver_interface $cache Cache driver + * @param phpbb_cache_driver_driver_interface $cache Cache driver */ - public function __construct(phpbb_config $config, $phpbb_root_path, $php_ext, phpbb_cache_driver_interface $cache = null) + public function __construct(phpbb_config $config, $phpbb_root_path, $php_ext, phpbb_cache_driver_driver_interface $cache = null) { $this->config = $config; $this->phpbb_root_path = $phpbb_root_path; diff --git a/phpBB/phpbb/cache/driver/base.php b/phpBB/phpbb/cache/driver/base.php index 32e04f813a..7ee7e82ad5 100644 --- a/phpBB/phpbb/cache/driver/base.php +++ b/phpBB/phpbb/cache/driver/base.php @@ -18,6 +18,6 @@ if (!defined('IN_PHPBB')) /** * @package acm */ -abstract class phpbb_cache_driver_base implements phpbb_cache_driver_interface +abstract class phpbb_cache_driver_base implements phpbb_cache_driver_driver_interface { } diff --git a/phpBB/phpbb/cache/service.php b/phpBB/phpbb/cache/service.php index 69c5e0fdd0..02dd3d48a9 100644 --- a/phpBB/phpbb/cache/service.php +++ b/phpBB/phpbb/cache/service.php @@ -24,7 +24,7 @@ class phpbb_cache_service /** * Cache driver. * - * @var phpbb_cache_driver_interface + * @var phpbb_cache_driver_driver_interface */ protected $driver; @@ -59,13 +59,13 @@ class phpbb_cache_service /** * Creates a cache service around a cache driver * - * @param phpbb_cache_driver_interface $driver The cache driver + * @param phpbb_cache_driver_driver_interface $driver The cache driver * @param phpbb_config $config The config * @param phpbb_db_driver $db Database connection * @param string $phpbb_root_path Root path * @param string $php_ext PHP extension */ - public function __construct(phpbb_cache_driver_interface $driver, phpbb_config $config, phpbb_db_driver $db, $phpbb_root_path, $php_ext) + public function __construct(phpbb_cache_driver_driver_interface $driver, phpbb_config $config, phpbb_db_driver $db, $phpbb_root_path, $php_ext) { $this->set_driver($driver); $this->config = $config; @@ -77,7 +77,7 @@ class phpbb_cache_service /** * Returns the cache driver used by this cache service. * - * @return phpbb_cache_driver_interface The cache driver + * @return phpbb_cache_driver_driver_interface The cache driver */ public function get_driver() { @@ -87,9 +87,9 @@ class phpbb_cache_service /** * Replaces the cache driver used by this cache service. * - * @param phpbb_cache_driver_interface $driver The cache driver + * @param phpbb_cache_driver_driver_interface $driver The cache driver */ - public function set_driver(phpbb_cache_driver_interface $driver) + public function set_driver(phpbb_cache_driver_driver_interface $driver) { $this->driver = $driver; } diff --git a/phpBB/phpbb/class_loader.php b/phpBB/phpbb/class_loader.php index 02a2d584dc..78467a044c 100644 --- a/phpBB/phpbb/class_loader.php +++ b/phpBB/phpbb/class_loader.php @@ -50,9 +50,9 @@ class phpbb_class_loader * @param string $prefix Required class name prefix for files to be loaded * @param string $path Directory to load files from * @param string $php_ext The file extension for PHP files - * @param phpbb_cache_driver_interface $cache An implementation of the phpBB cache interface. + * @param phpbb_cache_driver_driver_interface $cache An implementation of the phpBB cache interface. */ - public function __construct($prefix, $path, $php_ext = 'php', phpbb_cache_driver_interface $cache = null) + public function __construct($prefix, $path, $php_ext = 'php', phpbb_cache_driver_driver_interface $cache = null) { $this->prefix = $prefix; $this->path = $path; @@ -66,9 +66,9 @@ class phpbb_class_loader * the class loader will resolve paths by checking for the existance of every * directory in the class name every time. * - * @param phpbb_cache_driver_interface $cache An implementation of the phpBB cache interface. + * @param phpbb_cache_driver_driver_interface $cache An implementation of the phpBB cache interface. */ - public function set_cache(phpbb_cache_driver_interface $cache = null) + public function set_cache(phpbb_cache_driver_driver_interface $cache = null) { if ($cache) { diff --git a/phpBB/phpbb/config/db.php b/phpBB/phpbb/config/db.php index b18369a479..25647e1d0b 100644 --- a/phpBB/phpbb/config/db.php +++ b/phpBB/phpbb/config/db.php @@ -23,7 +23,7 @@ class phpbb_config_db extends phpbb_config { /** * Cache instance - * @var phpbb_cache_driver_interface + * @var phpbb_cache_driver_driver_interface */ protected $cache; @@ -43,10 +43,10 @@ class phpbb_config_db extends phpbb_config * Creates a configuration container with a default set of values * * @param phpbb_db_driver $db Database connection - * @param phpbb_cache_driver_interface $cache Cache instance + * @param phpbb_cache_driver_driver_interface $cache Cache instance * @param string $table Configuration table name */ - public function __construct(phpbb_db_driver $db, phpbb_cache_driver_interface $cache, $table) + public function __construct(phpbb_db_driver $db, phpbb_cache_driver_driver_interface $cache, $table) { $this->db = $db; $this->cache = $cache; diff --git a/phpBB/phpbb/cron/task/core/prune_forum.php b/phpBB/phpbb/cron/task/core/prune_forum.php index e3c497f072..0e4c75c77f 100644 --- a/phpBB/phpbb/cron/task/core/prune_forum.php +++ b/phpBB/phpbb/cron/task/core/prune_forum.php @@ -132,15 +132,15 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p /** * Parses parameters found in $request, which is an instance of - * phpbb_request_interface. + * phpbb_request_request_interface. * * It is expected to have a key f whose value is id of the forum to be pruned. * - * @param phpbb_request_interface $request Request object. + * @param phpbb_request_request_interface $request Request object. * * @return null */ - public function parse_parameters(phpbb_request_interface $request) + public function parse_parameters(phpbb_request_request_interface $request) { $this->forum_data = null; if ($request->is_set('f')) diff --git a/phpBB/phpbb/cron/task/core/tidy_cache.php b/phpBB/phpbb/cron/task/core/tidy_cache.php index 16a45dae7c..4618e8200e 100644 --- a/phpBB/phpbb/cron/task/core/tidy_cache.php +++ b/phpBB/phpbb/cron/task/core/tidy_cache.php @@ -29,9 +29,9 @@ class phpbb_cron_task_core_tidy_cache extends phpbb_cron_task_base * Constructor. * * @param phpbb_config $config The config - * @param phpbb_cache_driver_interface $cache The cache driver + * @param phpbb_cache_driver_driver_interface $cache The cache driver */ - public function __construct(phpbb_config $config, phpbb_cache_driver_interface $cache) + public function __construct(phpbb_config $config, phpbb_cache_driver_driver_interface $cache) { $this->config = $config; $this->cache = $cache; diff --git a/phpBB/phpbb/cron/task/parametrized.php b/phpBB/phpbb/cron/task/parametrized.php index 5f0e46eafc..9a6a55c6bc 100644 --- a/phpBB/phpbb/cron/task/parametrized.php +++ b/phpBB/phpbb/cron/task/parametrized.php @@ -39,14 +39,14 @@ interface phpbb_cron_task_parametrized extends phpbb_cron_task /** * Parses parameters found in $request, which is an instance of - * phpbb_request_interface. + * phpbb_request_request_interface. * * $request contains user input and must not be trusted. * Cron task must validate all data before using it. * - * @param phpbb_request_interface $request Request object. + * @param phpbb_request_request_interface $request Request object. * * @return null */ - public function parse_parameters(phpbb_request_interface $request); + public function parse_parameters(phpbb_request_request_interface $request); } diff --git a/phpBB/phpbb/db/migration/tool/config.php b/phpBB/phpbb/db/migration/tool/config.php index 0b626bf455..5dd47cfa60 100644 --- a/phpBB/phpbb/db/migration/tool/config.php +++ b/phpBB/phpbb/db/migration/tool/config.php @@ -12,7 +12,7 @@ * * @package db */ -class phpbb_db_migration_tool_config implements phpbb_db_migration_tool_interface +class phpbb_db_migration_tool_config implements phpbb_db_migration_tool_tool_interface { /** @var phpbb_config */ protected $config; diff --git a/phpBB/phpbb/db/migration/tool/module.php b/phpBB/phpbb/db/migration/tool/module.php index ac4d2c9bd7..8ed2a933ff 100644 --- a/phpBB/phpbb/db/migration/tool/module.php +++ b/phpBB/phpbb/db/migration/tool/module.php @@ -12,7 +12,7 @@ * * @package db */ -class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interface +class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_tool_interface { /** @var phpbb_cache_service */ protected $cache; diff --git a/phpBB/phpbb/db/migration/tool/permission.php b/phpBB/phpbb/db/migration/tool/permission.php index 2f09c0ac72..f1140d0759 100644 --- a/phpBB/phpbb/db/migration/tool/permission.php +++ b/phpBB/phpbb/db/migration/tool/permission.php @@ -12,7 +12,7 @@ * * @package db */ -class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_interface +class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_tool_interface { /** @var phpbb_auth */ protected $auth; diff --git a/phpBB/phpbb/extension/base.php b/phpBB/phpbb/extension/base.php index c4462b64d8..de18998106 100644 --- a/phpBB/phpbb/extension/base.php +++ b/phpBB/phpbb/extension/base.php @@ -22,7 +22,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; * * @package extension */ -class phpbb_extension_base implements phpbb_extension_interface +class phpbb_extension_base implements phpbb_extension_extension_interface { /** @var ContainerInterface */ protected $container; diff --git a/phpBB/phpbb/extension/finder.php b/phpBB/phpbb/extension/finder.php index 155a41cda5..1569c90eb8 100644 --- a/phpBB/phpbb/extension/finder.php +++ b/phpBB/phpbb/extension/finder.php @@ -57,12 +57,12 @@ class phpbb_extension_finder * extensions and their locations * @param phpbb_filesystem $filesystem Filesystem instance * @param string $phpbb_root_path Path to the phpbb root directory - * @param phpbb_cache_driver_interface $cache A cache instance or null + * @param phpbb_cache_driver_driver_interface $cache A cache instance or null * @param string $php_ext php file extension * @param string $cache_name The name of the cache variable, defaults to * _ext_finder */ - public function __construct(phpbb_extension_manager $extension_manager, phpbb_filesystem $filesystem, $phpbb_root_path = '', phpbb_cache_driver_interface $cache = null, $php_ext = 'php', $cache_name = '_ext_finder') + public function __construct(phpbb_extension_manager $extension_manager, phpbb_filesystem $filesystem, $phpbb_root_path = '', phpbb_cache_driver_driver_interface $cache = null, $php_ext = 'php', $cache_name = '_ext_finder') { $this->extension_manager = $extension_manager; $this->filesystem = $filesystem; diff --git a/phpBB/phpbb/extension/manager.php b/phpBB/phpbb/extension/manager.php index 4451049d04..f9f722f773 100644 --- a/phpBB/phpbb/extension/manager.php +++ b/phpBB/phpbb/extension/manager.php @@ -46,10 +46,10 @@ class phpbb_extension_manager * @param string $extension_table The name of the table holding extensions * @param string $phpbb_root_path Path to the phpbb includes directory. * @param string $php_ext php file extension - * @param phpbb_cache_driver_interface $cache A cache instance or null + * @param phpbb_cache_driver_driver_interface $cache A cache instance or null * @param string $cache_name The name of the cache variable, defaults to _ext */ - public function __construct(ContainerInterface $container, phpbb_db_driver $db, phpbb_config $config, phpbb_filesystem $filesystem, $extension_table, $phpbb_root_path, $php_ext = 'php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext') + public function __construct(ContainerInterface $container, phpbb_db_driver $db, phpbb_config $config, phpbb_filesystem $filesystem, $extension_table, $phpbb_root_path, $php_ext = 'php', phpbb_cache_driver_driver_interface $cache = null, $cache_name = '_ext') { $this->container = $container; $this->phpbb_root_path = $phpbb_root_path; @@ -126,7 +126,7 @@ class phpbb_extension_manager * Instantiates the extension meta class for the extension with the given name * * @param string $name The extension name - * @return phpbb_extension_interface Instance of the extension meta class or + * @return phpbb_extension_extension_interface Instance of the extension meta class or * phpbb_extension_base if the class does not exist */ public function get_extension($name) diff --git a/phpBB/phpbb/feed/base.php b/phpBB/phpbb/feed/base.php index 296d830932..9a38e604a3 100644 --- a/phpBB/phpbb/feed/base.php +++ b/phpBB/phpbb/feed/base.php @@ -34,7 +34,7 @@ abstract class phpbb_feed_base /** @var phpbb_db_driver */ protected $db; - /** @var phpbb_cache_driver_interface */ + /** @var phpbb_cache_driver_driver_interface */ protected $cache; /** @var phpbb_user */ @@ -77,14 +77,14 @@ abstract class phpbb_feed_base * @param phpbb_feed_helper $helper Feed helper * @param phpbb_config $config Config object * @param phpbb_db_driver $db Database connection - * @param phpbb_cache_driver_interface $cache Cache object + * @param phpbb_cache_driver_driver_interface $cache Cache object * @param phpbb_user $user User object * @param phpbb_auth $auth Auth object * @param phpbb_content_visibility $content_visibility Auth object * @param string $phpEx php file extension * @return null */ - function __construct(phpbb_feed_helper $helper, phpbb_config $config, phpbb_db_driver $db, phpbb_cache_driver_interface $cache, phpbb_user $user, phpbb_auth $auth, phpbb_content_visibility $content_visibility, $phpEx) + function __construct(phpbb_feed_helper $helper, phpbb_config $config, phpbb_db_driver $db, phpbb_cache_driver_driver_interface $cache, phpbb_user $user, phpbb_auth $auth, phpbb_content_visibility $content_visibility, $phpEx) { $this->config = $config; $this->helper = $helper; diff --git a/phpBB/phpbb/groupposition/legend.php b/phpBB/phpbb/groupposition/legend.php index 7fddadde99..5cbc26f528 100644 --- a/phpBB/phpbb/groupposition/legend.php +++ b/phpBB/phpbb/groupposition/legend.php @@ -23,7 +23,7 @@ if (!defined('IN_PHPBB')) * * @package phpBB3 */ -class phpbb_groupposition_legend implements phpbb_groupposition_interface +class phpbb_groupposition_legend implements phpbb_groupposition_groupposition_interface { /** * Group is not displayed diff --git a/phpBB/phpbb/groupposition/teampage.php b/phpBB/phpbb/groupposition/teampage.php index 7c758199e7..6a0601da63 100644 --- a/phpBB/phpbb/groupposition/teampage.php +++ b/phpBB/phpbb/groupposition/teampage.php @@ -22,7 +22,7 @@ if (!defined('IN_PHPBB')) * * @package phpBB3 */ -class phpbb_groupposition_teampage implements phpbb_groupposition_interface +class phpbb_groupposition_teampage implements phpbb_groupposition_groupposition_interface { /** * Group is not displayed @@ -48,7 +48,7 @@ class phpbb_groupposition_teampage implements phpbb_groupposition_interface /** * Cache object - * @var phpbb_cache_driver_interface + * @var phpbb_cache_driver_driver_interface */ protected $cache; @@ -57,9 +57,9 @@ class phpbb_groupposition_teampage implements phpbb_groupposition_interface * * @param phpbb_db_driver $db Database object * @param phpbb_user $user User object - * @param phpbb_cache_driver_interface $cache Cache object + * @param phpbb_cache_driver_driver_interface $cache Cache object */ - public function __construct(phpbb_db_driver $db, phpbb_user $user, phpbb_cache_driver_interface $cache) + public function __construct(phpbb_db_driver $db, phpbb_user $user, phpbb_cache_driver_driver_interface $cache) { $this->db = $db; $this->user = $user; diff --git a/phpBB/phpbb/hook/finder.php b/phpBB/phpbb/hook/finder.php index 7b0412f733..3f9758211d 100644 --- a/phpBB/phpbb/hook/finder.php +++ b/phpBB/phpbb/hook/finder.php @@ -31,9 +31,9 @@ class phpbb_hook_finder * * @param string $phpbb_root_path Path to the phpbb root directory * @param string $php_ext php file extension - * @param phpbb_cache_driver_interface $cache A cache instance or null + * @param phpbb_cache_driver_driver_interface $cache A cache instance or null */ - public function __construct($phpbb_root_path, $php_ext, phpbb_cache_driver_interface $cache = null) + public function __construct($phpbb_root_path, $php_ext, phpbb_cache_driver_driver_interface $cache = null) { $this->phpbb_root_path = $phpbb_root_path; $this->cache = $cache; diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 7a26858348..0a755b5c78 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -20,7 +20,7 @@ if (!defined('IN_PHPBB')) * * @package phpbb_log */ -class phpbb_log implements phpbb_log_interface +class phpbb_log implements phpbb_log_log_interface { /** * If set, administrative user profile links will be returned and messages diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php index 97833710c0..32e0ef50bc 100644 --- a/phpBB/phpbb/notification/manager.php +++ b/phpBB/phpbb/notification/manager.php @@ -525,7 +525,7 @@ class phpbb_notification_manager { $type = $this->get_item_type_class($type_name); - if ($type instanceof phpbb_notification_type_interface && $type->is_available()) + if ($type instanceof phpbb_notification_type_type_interface && $type->is_available()) { $options = array_merge(array( 'id' => $type->get_type(), @@ -561,7 +561,7 @@ class phpbb_notification_manager { $method = $this->get_method_class($method_name); - if ($method instanceof phpbb_notification_method_interface && $method->is_available()) + if ($method instanceof phpbb_notification_method_method_interface && $method->is_available()) { $subscription_methods[$method_name] = array( 'id' => $method->get_type(), diff --git a/phpBB/phpbb/notification/method/base.php b/phpBB/phpbb/notification/method/base.php index b633956d01..fbff75b59f 100644 --- a/phpBB/phpbb/notification/method/base.php +++ b/phpBB/phpbb/notification/method/base.php @@ -19,7 +19,7 @@ if (!defined('IN_PHPBB')) * Base notifications method class * @package notifications */ -abstract class phpbb_notification_method_base implements phpbb_notification_method_interface +abstract class phpbb_notification_method_base implements phpbb_notification_method_method_interface { /** @var phpbb_notification_manager */ protected $notification_manager; @@ -30,7 +30,7 @@ abstract class phpbb_notification_method_base implements phpbb_notification_meth /** @var phpbb_db_driver */ protected $db; - /** @var phpbb_cache_driver_interface */ + /** @var phpbb_cache_driver_driver_interface */ protected $cache; /** @var phpbb_template */ @@ -66,7 +66,7 @@ abstract class phpbb_notification_method_base implements phpbb_notification_meth * * @param phpbb_user_loader $user_loader * @param phpbb_db_driver $db - * @param phpbb_cache_driver_interface $cache + * @param phpbb_cache_driver_driver_interface $cache * @param phpbb_user $user * @param phpbb_auth $auth * @param phpbb_config $config @@ -74,7 +74,7 @@ abstract class phpbb_notification_method_base implements phpbb_notification_meth * @param string $php_ext * @return phpbb_notification_method_base */ - public function __construct(phpbb_user_loader $user_loader, phpbb_db_driver $db, phpbb_cache_driver_interface $cache, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext) + public function __construct(phpbb_user_loader $user_loader, phpbb_db_driver $db, phpbb_cache_driver_driver_interface $cache, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext) { $this->user_loader = $user_loader; $this->db = $db; @@ -99,9 +99,9 @@ abstract class phpbb_notification_method_base implements phpbb_notification_meth /** * Add a notification to the queue * - * @param phpbb_notification_type_interface $notification + * @param phpbb_notification_type_type_interface $notification */ - public function add_to_queue(phpbb_notification_type_interface $notification) + public function add_to_queue(phpbb_notification_type_type_interface $notification) { $this->queue[] = $notification; } diff --git a/phpBB/phpbb/notification/method/method_interface.php b/phpBB/phpbb/notification/method/method_interface.php index b3ca757d5f..bd21d924e4 100644 --- a/phpBB/phpbb/notification/method/method_interface.php +++ b/phpBB/phpbb/notification/method/method_interface.php @@ -37,9 +37,9 @@ interface phpbb_notification_method_method_interface /** * Add a notification to the queue * - * @param phpbb_notification_type_interface $notification + * @param phpbb_notification_type_type_interface $notification */ - public function add_to_queue(phpbb_notification_type_interface $notification); + public function add_to_queue(phpbb_notification_type_type_interface $notification); /** * Parse the queue and notify the users diff --git a/phpBB/phpbb/notification/type/base.php b/phpBB/phpbb/notification/type/base.php index 46517f1c9b..a7434fc9a7 100644 --- a/phpBB/phpbb/notification/type/base.php +++ b/phpBB/phpbb/notification/type/base.php @@ -19,7 +19,7 @@ if (!defined('IN_PHPBB')) * Base notifications class * @package notifications */ -abstract class phpbb_notification_type_base implements phpbb_notification_type_interface +abstract class phpbb_notification_type_base implements phpbb_notification_type_type_interface { /** @var phpbb_notification_manager */ protected $notification_manager; @@ -30,7 +30,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i /** @var phpbb_db_driver */ protected $db; - /** @var phpbb_cache_driver_interface */ + /** @var phpbb_cache_driver_driver_interface */ protected $cache; /** @var phpbb_template */ @@ -96,7 +96,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i * * @param phpbb_user_loader $user_loader * @param phpbb_db_driver $db - * @param phpbb_cache_driver_interface $cache + * @param phpbb_cache_driver_driver_interface $cache * @param phpbb_user $user * @param phpbb_auth $auth * @param phpbb_config $config @@ -107,7 +107,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i * @param string $user_notifications_table * @return phpbb_notification_type_base */ - public function __construct(phpbb_user_loader $user_loader, phpbb_db_driver $db, phpbb_cache_driver_interface $cache, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table) + public function __construct(phpbb_user_loader $user_loader, phpbb_db_driver $db, phpbb_cache_driver_driver_interface $cache, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table) { $this->user_loader = $user_loader; $this->db = $db; diff --git a/phpBB/phpbb/request/deactivated_super_global.php b/phpBB/phpbb/request/deactivated_super_global.php index cc05847ec7..9ca0f462b4 100644 --- a/phpBB/phpbb/request/deactivated_super_global.php +++ b/phpBB/phpbb/request/deactivated_super_global.php @@ -29,23 +29,23 @@ class phpbb_request_deactivated_super_global implements ArrayAccess, Countable, private $name; /** - * @var phpbb_request_interface::POST|GET|REQUEST|COOKIE Super global constant. + * @var phpbb_request_request_interface::POST|GET|REQUEST|COOKIE Super global constant. */ private $super_global; /** - * @var phpbb_request_interface The request class instance holding the actual request data. + * @var phpbb_request_request_interface The request class instance holding the actual request data. */ private $request; /** * Constructor generates an error message fitting the super global to be used within the other functions. * - * @param phpbb_request_interface $request A request class instance holding the real super global data. + * @param phpbb_request_request_interface $request A request class instance holding the real super global data. * @param string $name Name of the super global this is a replacement for - e.g. '_GET'. - * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global The variable's super global constant. + * @param phpbb_request_request_interface::POST|GET|REQUEST|COOKIE $super_global The variable's super global constant. */ - public function __construct(phpbb_request_interface $request, $name, $super_global) + public function __construct(phpbb_request_request_interface $request, $name, $super_global) { $this->request = $request; $this->name = $name; diff --git a/phpBB/phpbb/request/request.php b/phpBB/phpbb/request/request.php index ae3c526d89..8c5bc12d96 100644 --- a/phpBB/phpbb/request/request.php +++ b/phpBB/phpbb/request/request.php @@ -23,18 +23,18 @@ if (!defined('IN_PHPBB')) * * @package phpbb_request */ -class phpbb_request implements phpbb_request_interface +class phpbb_request implements phpbb_request_request_interface { /** * @var array The names of super global variables that this class should protect if super globals are disabled. */ protected $super_globals = array( - phpbb_request_interface::POST => '_POST', - phpbb_request_interface::GET => '_GET', - phpbb_request_interface::REQUEST => '_REQUEST', - phpbb_request_interface::COOKIE => '_COOKIE', - phpbb_request_interface::SERVER => '_SERVER', - phpbb_request_interface::FILES => '_FILES', + phpbb_request_request_interface::POST => '_POST', + phpbb_request_request_interface::GET => '_GET', + phpbb_request_request_interface::REQUEST => '_REQUEST', + phpbb_request_request_interface::COOKIE => '_COOKIE', + phpbb_request_request_interface::SERVER => '_SERVER', + phpbb_request_request_interface::FILES => '_FILES', ); /** @@ -78,8 +78,8 @@ class phpbb_request implements phpbb_request_interface } // simulate request_order = GP - $this->original_request = $this->input[phpbb_request_interface::REQUEST]; - $this->input[phpbb_request_interface::REQUEST] = $this->input[phpbb_request_interface::POST] + $this->input[phpbb_request_interface::GET]; + $this->original_request = $this->input[phpbb_request_request_interface::REQUEST]; + $this->input[phpbb_request_request_interface::REQUEST] = $this->input[phpbb_request_request_interface::POST] + $this->input[phpbb_request_request_interface::GET]; if ($disable_super_globals) { @@ -144,10 +144,10 @@ class phpbb_request implements phpbb_request_interface * @param string $var_name The name of the variable that shall be overwritten * @param mixed $value The value which the variable shall contain. * If this is null the variable will be unset. - * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global + * @param phpbb_request_request_interface::POST|GET|REQUEST|COOKIE $super_global * Specifies which super global shall be changed */ - public function overwrite($var_name, $value, $super_global = phpbb_request_interface::REQUEST) + public function overwrite($var_name, $value, $super_global = phpbb_request_request_interface::REQUEST) { if (!isset($this->super_globals[$super_global])) { @@ -193,13 +193,13 @@ class phpbb_request implements phpbb_request_interface * This function will always return a value of the same type as the default. * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks - * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global + * @param phpbb_request_request_interface::POST|GET|REQUEST|COOKIE $super_global * Specifies which super global should be used * * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the * the same as that of $default. If the variable is not set $default is returned. */ - public function variable($var_name, $default, $multibyte = false, $super_global = phpbb_request_interface::REQUEST) + public function variable($var_name, $default, $multibyte = false, $super_global = phpbb_request_request_interface::REQUEST) { return $this->_variable($var_name, $default, $multibyte, $super_global, true); } @@ -217,13 +217,13 @@ class phpbb_request implements phpbb_request_interface * This function will always return a value of the same type as the default. * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks - * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global + * @param phpbb_request_request_interface::POST|GET|REQUEST|COOKIE $super_global * Specifies which super global should be used * * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the * the same as that of $default. If the variable is not set $default is returned. */ - public function untrimmed_variable($var_name, $default, $multibyte, $super_global = phpbb_request_interface::REQUEST) + public function untrimmed_variable($var_name, $default, $multibyte, $super_global = phpbb_request_request_interface::REQUEST) { return $this->_variable($var_name, $default, $multibyte, $super_global, false); } @@ -234,8 +234,8 @@ class phpbb_request implements phpbb_request_interface * Also fall back to getenv(), some CGI setups may need it (probably not, but * whatever). * - * @param string|array $var_name See phpbb_request_interface::variable - * @param mixed $Default See phpbb_request_interface::variable + * @param string|array $var_name See phpbb_request_request_interface::variable + * @param mixed $Default See phpbb_request_request_interface::variable * * @return mixed The server variable value. */ @@ -243,9 +243,9 @@ class phpbb_request implements phpbb_request_interface { $multibyte = true; - if ($this->is_set($var_name, phpbb_request_interface::SERVER)) + if ($this->is_set($var_name, phpbb_request_request_interface::SERVER)) { - return $this->variable($var_name, $default, $multibyte, phpbb_request_interface::SERVER); + return $this->variable($var_name, $default, $multibyte, phpbb_request_request_interface::SERVER); } else { @@ -259,7 +259,7 @@ class phpbb_request implements phpbb_request_interface * Shortcut method to retrieve the value of client HTTP headers. * * @param string|array $header_name The name of the header to retrieve. - * @param mixed $default See phpbb_request_interface::variable + * @param mixed $default See phpbb_request_request_interface::variable * * @return mixed The header value. */ @@ -279,7 +279,7 @@ class phpbb_request implements phpbb_request_interface */ public function file($form_name) { - return $this->variable($form_name, array('name' => 'none'), false, phpbb_request_interface::FILES); + return $this->variable($form_name, array('name' => 'none'), false, phpbb_request_request_interface::FILES); } /** @@ -294,7 +294,7 @@ class phpbb_request implements phpbb_request_interface */ public function is_set_post($name) { - return $this->is_set($name, phpbb_request_interface::POST); + return $this->is_set($name, phpbb_request_request_interface::POST); } /** @@ -302,12 +302,12 @@ class phpbb_request implements phpbb_request_interface * arrays. * * @param string $var Name of the variable - * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global + * @param phpbb_request_request_interface::POST|GET|REQUEST|COOKIE $super_global * Specifies the super global which shall be checked * * @return bool True if the variable was sent as input */ - public function is_set($var, $super_global = phpbb_request_interface::REQUEST) + public function is_set($var, $super_global = phpbb_request_request_interface::REQUEST) { return isset($this->input[$super_global][$var]); } @@ -335,13 +335,13 @@ class phpbb_request implements phpbb_request_interface /** * Returns all variable names for a given super global * - * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global + * @param phpbb_request_request_interface::POST|GET|REQUEST|COOKIE $super_global * The super global from which names shall be taken * * @return array All variable names that are set for the super global. * Pay attention when using these, they are unsanitised! */ - public function variable_names($super_global = phpbb_request_interface::REQUEST) + public function variable_names($super_global = phpbb_request_request_interface::REQUEST) { if (!isset($this->input[$super_global])) { @@ -362,14 +362,14 @@ class phpbb_request implements phpbb_request_interface * This function will always return a value of the same type as the default. * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks - * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global + * @param phpbb_request_request_interface::POST|GET|REQUEST|COOKIE $super_global * Specifies which super global should be used * @param bool $trim Indicates whether trim() should be applied to string values. * * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the * the same as that of $default. If the variable is not set $default is returned. */ - protected function _variable($var_name, $default, $multibyte = false, $super_global = phpbb_request_interface::REQUEST, $trim = true) + protected function _variable($var_name, $default, $multibyte = false, $super_global = phpbb_request_request_interface::REQUEST, $trim = true) { $path = false; diff --git a/phpBB/phpbb/request/request_interface.php b/phpBB/phpbb/request/request_interface.php index 482f0f1287..2c804cd7fd 100644 --- a/phpBB/phpbb/request/request_interface.php +++ b/phpBB/phpbb/request/request_interface.php @@ -43,10 +43,10 @@ interface phpbb_request_request_interface * @param string $var_name The name of the variable that shall be overwritten * @param mixed $value The value which the variable shall contain. * If this is null the variable will be unset. - * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global + * @param phpbb_request_request_interface::POST|GET|REQUEST|COOKIE $super_global * Specifies which super global shall be changed */ - public function overwrite($var_name, $value, $super_global = phpbb_request_interface::REQUEST); + public function overwrite($var_name, $value, $super_global = phpbb_request_request_interface::REQUEST); /** * Central type safe input handling function. @@ -60,19 +60,19 @@ interface phpbb_request_request_interface * This function will always return a value of the same type as the default. * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks - * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global + * @param phpbb_request_request_interface::POST|GET|REQUEST|COOKIE $super_global * Specifies which super global should be used * * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the * the same as that of $default. If the variable is not set $default is returned. */ - public function variable($var_name, $default, $multibyte = false, $super_global = phpbb_request_interface::REQUEST); + public function variable($var_name, $default, $multibyte = false, $super_global = phpbb_request_request_interface::REQUEST); /** * Shortcut method to retrieve SERVER variables. * - * @param string|array $var_name See phpbb_request_interface::variable - * @param mixed $default See phpbb_request_interface::variable + * @param string|array $var_name See phpbb_request_request_interface::variable + * @param mixed $default See phpbb_request_request_interface::variable * * @return mixed The server variable value. */ @@ -82,7 +82,7 @@ interface phpbb_request_request_interface * Shortcut method to retrieve the value of client HTTP headers. * * @param string|array $header_name The name of the header to retrieve. - * @param mixed $default See phpbb_request_interface::variable + * @param mixed $default See phpbb_request_request_interface::variable * * @return mixed The header value. */ @@ -105,12 +105,12 @@ interface phpbb_request_request_interface * arrays. * * @param string $var Name of the variable - * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global + * @param phpbb_request_request_interface::POST|GET|REQUEST|COOKIE $super_global * Specifies the super global which shall be checked * * @return bool True if the variable was sent as input */ - public function is_set($var, $super_global = phpbb_request_interface::REQUEST); + public function is_set($var, $super_global = phpbb_request_request_interface::REQUEST); /** * Checks whether the current request is an AJAX request (XMLHttpRequest) @@ -129,11 +129,11 @@ interface phpbb_request_request_interface /** * Returns all variable names for a given super global * - * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global + * @param phpbb_request_request_interface::POST|GET|REQUEST|COOKIE $super_global * The super global from which names shall be taken * * @return array All variable names that are set for the super global. * Pay attention when using these, they are unsanitised! */ - public function variable_names($super_global = phpbb_request_interface::REQUEST); + public function variable_names($super_global = phpbb_request_request_interface::REQUEST); } diff --git a/phpBB/phpbb/session.php b/phpBB/phpbb/session.php index e0585b1523..3bff91e275 100644 --- a/phpBB/phpbb/session.php +++ b/phpBB/phpbb/session.php @@ -243,7 +243,7 @@ class phpbb_session $this->forwarded_for = ''; } - if ($request->is_set($config['cookie_name'] . '_sid', phpbb_request_interface::COOKIE) || $request->is_set($config['cookie_name'] . '_u', phpbb_request_interface::COOKIE)) + if ($request->is_set($config['cookie_name'] . '_sid', phpbb_request_request_interface::COOKIE) || $request->is_set($config['cookie_name'] . '_u', phpbb_request_request_interface::COOKIE)) { $this->cookie_data['u'] = request_var($config['cookie_name'] . '_u', 0, false, true); $this->cookie_data['k'] = request_var($config['cookie_name'] . '_k', '', false, true); @@ -405,9 +405,9 @@ class phpbb_session $provider = $phpbb_container->get('auth.provider.' . $method); - if (!($provider instanceof phpbb_auth_provider_interface)) + if (!($provider instanceof phpbb_auth_provider_provider_interface)) { - throw new \RuntimeException($provider . ' must implement phpbb_auth_provider_interface'); + throw new \RuntimeException($provider . ' must implement phpbb_auth_provider_provider_interface'); } $ret = $provider->validate_session($this->data); diff --git a/phpBB/phpbb/tree/nestedset.php b/phpBB/phpbb/tree/nestedset.php index 4d851a87a8..79853eeaa1 100644 --- a/phpBB/phpbb/tree/nestedset.php +++ b/phpBB/phpbb/tree/nestedset.php @@ -15,7 +15,7 @@ if (!defined('IN_PHPBB')) exit; } -abstract class phpbb_tree_nestedset implements phpbb_tree_interface +abstract class phpbb_tree_nestedset implements phpbb_tree_tree_interface { /** @var phpbb_db_driver */ protected $db; diff --git a/phpBB/posting.php b/phpBB/posting.php index ac459197b3..f9d5295320 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -697,7 +697,7 @@ if ($submit || $preview || $refresh) $message_parser->message = utf8_normalize_nfc(request_var('message', '', true)); $post_data['username'] = utf8_normalize_nfc(request_var('username', $post_data['username'], true)); - $post_data['post_edit_reason'] = ($request->variable('edit_reason', false, false, phpbb_request_interface::POST) && $mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? utf8_normalize_nfc(request_var('edit_reason', '', true)) : ''; + $post_data['post_edit_reason'] = ($request->variable('edit_reason', false, false, phpbb_request_request_interface::POST) && $mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? utf8_normalize_nfc(request_var('edit_reason', '', true)) : ''; $post_data['orig_topic_type'] = $post_data['topic_type']; $post_data['topic_type'] = request_var('topic_type', (($mode != 'post') ? (int) $post_data['topic_type'] : POST_NORMAL)); diff --git a/phpBB/search.php b/phpBB/search.php index 2429c81dae..6da74b954f 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -683,7 +683,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) if ($config['load_anon_lastread'] || ($user->data['is_registered'] && !$config['load_db_lastread'])) { - $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/ucp.php b/phpBB/ucp.php index 7180c54de6..b1e576fee8 100644 --- a/phpBB/ucp.php +++ b/phpBB/ucp.php @@ -139,9 +139,9 @@ switch ($mode) { $set_time = time() - 31536000; - foreach ($request->variable_names(phpbb_request_interface::COOKIE) as $cookie_name) + foreach ($request->variable_names(phpbb_request_request_interface::COOKIE) as $cookie_name) { - $cookie_data = $request->variable($cookie_name, '', true, phpbb_request_interface::COOKIE); + $cookie_data = $request->variable($cookie_name, '', true, phpbb_request_request_interface::COOKIE); // Only delete board cookies, no other ones... if (strpos($cookie_name, $config['cookie_name'] . '_') !== 0) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 1e444f47ad..fb4fcf42bf 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -716,9 +716,9 @@ if (!empty($topic_data['poll_start'])) // Cookie based guest tracking ... I don't like this but hum ho // it's oft requested. This relies on "nice" users who don't feel // the need to delete cookies to mess with results. - if ($request->is_set($config['cookie_name'] . '_poll_' . $topic_id, phpbb_request_interface::COOKIE)) + if ($request->is_set($config['cookie_name'] . '_poll_' . $topic_id, phpbb_request_request_interface::COOKIE)) { - $cur_voted_id = explode(',', $request->variable($config['cookie_name'] . '_poll_' . $topic_id, '', true, phpbb_request_interface::COOKIE)); + $cur_voted_id = explode(',', $request->variable($config['cookie_name'] . '_poll_' . $topic_id, '', true, phpbb_request_request_interface::COOKIE)); $cur_voted_id = array_map('intval', $cur_voted_id); } } -- cgit v1.2.1 From d4d3d311b926cf3d0df4b3c6ccc4731a0345ca18 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 14 Jul 2013 13:54:56 -0400 Subject: [ticket/11700] Implement namespace loading in the class loader PHPBB3-11700 --- phpBB/phpbb/class_loader.php | 49 ++++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 31 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/class_loader.php b/phpBB/phpbb/class_loader.php index 78467a044c..bcd05e5853 100644 --- a/phpBB/phpbb/class_loader.php +++ b/phpBB/phpbb/class_loader.php @@ -7,6 +7,8 @@ * */ +namespace phpbb; + /** * @ignore */ @@ -28,9 +30,9 @@ if (!defined('IN_PHPBB')) * * @package phpBB3 */ -class phpbb_class_loader +class class_loader { - private $prefix; + private $namespace; private $path; private $php_ext; private $cache; @@ -44,17 +46,17 @@ class phpbb_class_loader private $cached_paths = array(); /** - * Creates a new phpbb_class_loader, which loads files with the given + * Creates a new \phpbb\class_loader, which loads files with the given * file extension from the given path. * - * @param string $prefix Required class name prefix for files to be loaded + * @param string $namespace Required namespace for files to be loaded * @param string $path Directory to load files from * @param string $php_ext The file extension for PHP files - * @param phpbb_cache_driver_driver_interface $cache An implementation of the phpBB cache interface. + * @param \phpbb\cache\driver\driver_interface $cache An implementation of the phpBB cache interface. */ - public function __construct($prefix, $path, $php_ext = 'php', phpbb_cache_driver_driver_interface $cache = null) + public function __construct($namespace, $path, $php_ext = 'php', \phpbb\cache\driver\driver_interface $cache = null) { - $this->prefix = $prefix; + $this->namespace = $namespace; $this->path = $path; $this->php_ext = $php_ext; @@ -66,13 +68,13 @@ class phpbb_class_loader * the class loader will resolve paths by checking for the existance of every * directory in the class name every time. * - * @param phpbb_cache_driver_driver_interface $cache An implementation of the phpBB cache interface. + * @param \phpbb\cache\driver\driver_interface $cache An implementation of the phpBB cache interface. */ - public function set_cache(phpbb_cache_driver_driver_interface $cache = null) + public function set_cache(\phpbb\cache\driver\driver_interface $cache = null) { if ($cache) { - $this->cached_paths = $cache->get('class_loader_' . $this->prefix); + $this->cached_paths = $cache->get('class_loader_' . str_replace('\\', '__', $this->namespace)); if ($this->cached_paths === false) { @@ -102,8 +104,8 @@ class phpbb_class_loader /** * Resolves a phpBB class name to a relative path which can be included. * - * @param string $class The class name to resolve, must have a phpbb_ - * prefix + * @param string $class The class name to resolve, must be in the + * namespace the loader was constructed with * @return string|bool A relative path to the file containing the * class or false if looking it up failed. */ @@ -114,27 +116,12 @@ class phpbb_class_loader return $this->path . $this->cached_paths[$class] . '.' . $this->php_ext; } - if (!preg_match('/^' . $this->prefix . '[a-zA-Z0-9_]+$/', $class)) + if (!preg_match('/^' . preg_quote($this->namespace, '/') . '[a-zA-Z0-9_\\\\]+$/', $class)) { return false; } - $parts = explode('_', substr($class, strlen($this->prefix))); - - $dirs = ''; - - for ($i = 0, $n = sizeof($parts); $i < $n && is_dir($this->path . $dirs . $parts[$i]); $i++) - { - $dirs .= $parts[$i] . '/'; - } - - // no file name left => use last dir name as file name - if ($i == sizeof($parts)) - { - $parts[] = $parts[$i - 1]; - } - - $relative_path = $dirs . implode(array_slice($parts, $i, sizeof($parts) - $i), '_'); + $relative_path = str_replace('\\', '/', substr($class, strlen($this->namespace))); if (!file_exists($this->path . $relative_path . '.' . $this->php_ext)) { @@ -144,7 +131,7 @@ class phpbb_class_loader if ($this->cache) { $this->cached_paths[$class] = $relative_path; - $this->cache->put('class_loader_' . $this->prefix, $this->cached_paths); + $this->cache->put('class_loader_' . str_replace('\\', '__', $this->namespace), $this->cached_paths); } return $this->path . $relative_path . '.' . $this->php_ext; @@ -157,7 +144,7 @@ class phpbb_class_loader */ public function load_class($class) { - if (substr($class, 0, strlen($this->prefix)) === $this->prefix) + if (substr($class, 0, strlen($this->namespace)) === $this->namespace) { $path = $this->resolve_path($class); -- cgit v1.2.1 From 3254f7c02bc34d962705e94cea528969441d4b11 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Fri, 12 Jul 2013 16:22:58 -0400 Subject: [feature/oauth] Include OAuth library in composer.json PHPBB3-11673 --- phpBB/composer.json | 1 + phpBB/composer.lock | 70 ++++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 59 insertions(+), 12 deletions(-) (limited to 'phpBB') diff --git a/phpBB/composer.json b/phpBB/composer.json index bf693d1950..20fe42735b 100644 --- a/phpBB/composer.json +++ b/phpBB/composer.json @@ -1,6 +1,7 @@ { "minimum-stability": "beta", "require": { + "lusitanian/oauth": "0.1.*@dev", "symfony/config": "2.1.*", "symfony/dependency-injection": "2.1.*", "symfony/event-dispatcher": "2.1.*", diff --git a/phpBB/composer.lock b/phpBB/composer.lock index 1ba6cb6f83..4bd73be2fe 100644 --- a/phpBB/composer.lock +++ b/phpBB/composer.lock @@ -3,8 +3,62 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "6e6125b88160e28568edcb9fd007abed", + "hash": "2b416686326d0308f977924abc825639", "packages": [ + { + "name": "lusitanian/oauth", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/Lusitanian/PHPoAuthLib.git", + "reference": "b7e96d0c36f17aa8a217b6be897363bb2cc93286" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Lusitanian/PHPoAuthLib/zipball/b7e96d0c36f17aa8a217b6be897363bb2cc93286", + "reference": "b7e96d0c36f17aa8a217b6be897363bb2cc93286", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "symfony/http-foundation": "~2.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.1-dev" + } + }, + "autoload": { + "psr-0": { + "OAuth": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "David Desberg", + "email": "david@daviddesberg.com" + }, + { + "name": "Pieter Hordijk", + "email": "info@pieterhordijk.com" + } + ], + "description": "PHP 5.3+ oAuth 1/2 Library", + "keywords": [ + "Authentication", + "authorization", + "oauth", + "security" + ], + "time": "2013-07-12 12:56:37" + }, { "name": "symfony/config", "version": "v2.1.11", @@ -29,7 +83,6 @@ "Symfony\\Component\\Config": "" } }, - "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -79,7 +132,6 @@ "Symfony\\Component\\DependencyInjection": "" } }, - "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -128,7 +180,6 @@ "Symfony\\Component\\EventDispatcher": "" } }, - "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -171,7 +222,6 @@ "SessionHandlerInterface": "Symfony/Component/HttpFoundation/Resources/stubs" } }, - "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -233,7 +283,6 @@ "Symfony\\Component\\HttpKernel": "" } }, - "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -286,7 +335,6 @@ "Symfony\\Component\\Routing": "" } }, - "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -328,7 +376,6 @@ "Symfony\\Component\\Yaml": "" } }, - "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -374,7 +421,6 @@ "Twig_": "lib/" } }, - "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3" ], @@ -1242,9 +1288,9 @@ ], "minimum-stability": "beta", - "stability-flags": [ - - ], + "stability-flags": { + "lusitanian/oauth": 20 + }, "platform": [ ], -- cgit v1.2.1 From 6a29d9cf81249aeb844cf8eba1faf3a4f2653e82 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 13 Jul 2013 10:28:13 -0400 Subject: [feature/oauth] OAuth provider skeleton PHPBB3-11673 --- phpBB/includes/auth/provider/oauth.php | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 phpBB/includes/auth/provider/oauth.php (limited to 'phpBB') diff --git a/phpBB/includes/auth/provider/oauth.php b/phpBB/includes/auth/provider/oauth.php new file mode 100644 index 0000000000..1fecf490c8 --- /dev/null +++ b/phpBB/includes/auth/provider/oauth.php @@ -0,0 +1,48 @@ +db = $db; + $this->config = $config; + $this->request = $request; + $this->user = $user; + } + + /** + * {@inheritdoc} + */ + public function login($username, $password) + { + + } +} -- cgit v1.2.1 From 232a8c67403ba536e4404cb2357bbac0a1baa5a8 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 13 Jul 2013 10:30:54 -0400 Subject: [feature/oauth] OAuth as a symfony service PHPBB3-11673 --- phpBB/config/auth_providers.yml | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'phpBB') diff --git a/phpBB/config/auth_providers.yml b/phpBB/config/auth_providers.yml index bcc448e4d7..4d402e71f2 100644 --- a/phpBB/config/auth_providers.yml +++ b/phpBB/config/auth_providers.yml @@ -35,3 +35,12 @@ services: - @user tags: - { name: auth.provider } + auth.provider.oauth: + class: phpbb_auth_provider_oauth + arguments: + - @dbal.conn + - @config + - @request + - @user + tags: + - { name: auth.provider } -- cgit v1.2.1 From 65485253c9252340e5ff6556c7d34f40e87f4644 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 13 Jul 2013 11:07:42 -0400 Subject: [feature/oauth] Start implementing login PHPBB3-11673 --- phpBB/includes/auth/provider/oauth.php | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'phpBB') diff --git a/phpBB/includes/auth/provider/oauth.php b/phpBB/includes/auth/provider/oauth.php index 1fecf490c8..de7903b7a5 100644 --- a/phpBB/includes/auth/provider/oauth.php +++ b/phpBB/includes/auth/provider/oauth.php @@ -15,6 +15,9 @@ if (!defined('IN_PHPBB')) exit; } +use OAuth\Common\Consumer\Credentials; +use OAuth\Common\Http\Uri\Uri; + /** * OAuth authentication provider for phpBB3 * @@ -43,6 +46,51 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base */ public function login($username, $password) { + if (!$this->request->is_set_post('oauth_service')) + { + return array( + 'status' => LOGIN_ERROR_EXTERNAL_AUTH, + 'error_msg' => 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE', + 'user_row' => array('user_id' => ANONYMOUS), + ); + } + + $serviceFactory = new \OAuth\ServiceFactory(); + $uriFactory = new \OAuth\Common\Http\Uri\UriFactory(); + $currentUri = $uriFactory->createFromSuperGlobalArray((array)$_SERVER); + $currentUri->setQuery(''); + + // In-memory storage + $storage = new Memory(); + + // Setup the credentials for the requests + $credentials = new Credentials( + $servicesCredentials['github']['key'], + $servicesCredentials['github']['secret'], + $currentUri->getAbsoluteUri() + ); + + if ($this->request->is_set('code', phpbb_request_interface::GET)) + { + // Second pass: request access token, authenticate with phpBB + } else { + // First pass: get authorization uri, redirect to service + } + } + + /** + * + */ + protected function get_service_credentials($service) + { + return $service_credentials[$service]; + } + /** + * + */ + public function get_credentials() + { + return array(); } } -- cgit v1.2.1 From 1e38be3fa95d18d05c303d9c8be5af174dc6d07d Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 13 Jul 2013 11:19:35 -0400 Subject: [feature/oauth] Additional work on implementing login PHPBB3-11673 --- phpBB/includes/auth/provider/oauth.php | 35 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/auth/provider/oauth.php b/phpBB/includes/auth/provider/oauth.php index de7903b7a5..2004f87e97 100644 --- a/phpBB/includes/auth/provider/oauth.php +++ b/phpBB/includes/auth/provider/oauth.php @@ -46,7 +46,9 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base */ public function login($username, $password) { - if (!$this->request->is_set_post('oauth_service')) + // Requst the name of the OAuth service + $service = $this->request->variable('oauth_service', '', false, phpbb_request_interface::POST); + if ($service === '') { return array( 'status' => LOGIN_ERROR_EXTERNAL_AUTH, @@ -55,19 +57,23 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base ); } - $serviceFactory = new \OAuth\ServiceFactory(); - $uriFactory = new \OAuth\Common\Http\Uri\UriFactory(); - $currentUri = $uriFactory->createFromSuperGlobalArray((array)$_SERVER); - $currentUri->setQuery(''); + // Get the service credentials for the given service + $service_credentials = $this->get_credentials($service); + + + $service_factory = new \OAuth\ServiceFactory(); + $uri_factory = new \OAuth\Common\Http\Uri\UriFactory(); + $current_uri = $uri_factory->createFromSuperGlobalArray((array)$_SERVER); + $current_uri->setQuery(''); // In-memory storage $storage = new Memory(); // Setup the credentials for the requests $credentials = new Credentials( - $servicesCredentials['github']['key'], - $servicesCredentials['github']['secret'], - $currentUri->getAbsoluteUri() + $service_credentials['key'], + $service_credentials['secret'], + $current_uri->getAbsoluteUri() ); if ($this->request->is_set('code', phpbb_request_interface::GET)) @@ -83,14 +89,9 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base */ protected function get_service_credentials($service) { - return $service_credentials[$service]; - } - - /** - * - */ - public function get_credentials() - { - return array(); + return array( + 'key' => $this->config['auth_oauth_' . $service . '_key'], + 'secret' => $this->config['auth_oauth_' . $service . '_secret'], + ); } } -- cgit v1.2.1 From d63f920250b801cf9e2bc1929a40ade7526078ff Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 13 Jul 2013 11:29:00 -0400 Subject: [feature/oauth] Check that the service actually has settings PHPBB3-11673 --- phpBB/includes/auth/provider/oauth.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'phpBB') diff --git a/phpBB/includes/auth/provider/oauth.php b/phpBB/includes/auth/provider/oauth.php index 2004f87e97..cbb1d99004 100644 --- a/phpBB/includes/auth/provider/oauth.php +++ b/phpBB/includes/auth/provider/oauth.php @@ -60,6 +60,15 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base // Get the service credentials for the given service $service_credentials = $this->get_credentials($service); + // Check that the service has settings + if ($service_credentials['key'] == false || $service_credentials['secret'] == false) + { + return array( + 'status' => LOGIN_ERROR_EXTERNAL_AUTH, + 'error_msg' => 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE', + 'user_row' => array('user_id' => ANONYMOUS), + ); + } $service_factory = new \OAuth\ServiceFactory(); $uri_factory = new \OAuth\Common\Http\Uri\UriFactory(); -- cgit v1.2.1 From 6479a989c5c06939d791a73952226382918d8183 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 13 Jul 2013 11:56:18 -0400 Subject: [feature/oauth] Token Storage Skeleton PHPBB3-11673 --- phpBB/includes/auth/oauth/token_storage.php | 94 +++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 phpBB/includes/auth/oauth/token_storage.php (limited to 'phpBB') diff --git a/phpBB/includes/auth/oauth/token_storage.php b/phpBB/includes/auth/oauth/token_storage.php new file mode 100644 index 0000000000..2d3c58d25a --- /dev/null +++ b/phpBB/includes/auth/oauth/token_storage.php @@ -0,0 +1,94 @@ +driver = $driver; + } + + /** + * {@inheritdoc} + */ + public function retrieveAccessToken() + { + if( $this->cachedToken instanceOf TokenInterface ) { + return $this->token; + } + + // TODO: check to see if the token is cached + + throw new TokenNotFoundException('Token not stored'); + } + + /** + * {@inheritdoc} + */ + public function storeAccessToken(TokenInterface $token) + { + $this->cachedToken = $token; + // TODO: actually store the token + } + + /** + * {@inheritdoc} + */ + public function hasAccessToken() + { + if( $this->cachedToken ) { + return true; + } + + // TODO: check cache for token + return false; + } + + /** + * {@inheritdoc} + */ + public function clearToken() + { + $this->cachedToken = null; + // TODO: clear cache of the token + } +} -- cgit v1.2.1 From a6ff2397788134b5410d89a67a3860a32670997e Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 13 Jul 2013 12:06:05 -0400 Subject: [feature/oauth] Allow getting original global arrays from request PHPBB3-11673 --- phpBB/phpbb/request/interface.php | 10 ++++++++++ phpBB/phpbb/request/request.php | 8 ++++++++ 2 files changed, 18 insertions(+) (limited to 'phpBB') diff --git a/phpBB/phpbb/request/interface.php b/phpBB/phpbb/request/interface.php index 741db35917..8d472af97a 100644 --- a/phpBB/phpbb/request/interface.php +++ b/phpBB/phpbb/request/interface.php @@ -136,4 +136,14 @@ interface phpbb_request_interface * Pay attention when using these, they are unsanitised! */ public function variable_names($super_global = phpbb_request_interface::REQUEST); + + /** + * Returns the original array of the requested super global + * + * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global + * The super global which will be returned + * + * @return array The original array of the requested super global. + */ + public function original_global_values($super_global = phpbb_request_interface::REQUEST); } diff --git a/phpBB/phpbb/request/request.php b/phpBB/phpbb/request/request.php index ae3c526d89..a4e9a2c2b3 100644 --- a/phpBB/phpbb/request/request.php +++ b/phpBB/phpbb/request/request.php @@ -412,4 +412,12 @@ class phpbb_request implements phpbb_request_interface return $var; } + + /** + * {@inheritdoc} + */ + public function original_global_values($super_global = phpbb_request_interface::REQUEST) + { + return $this->input[$super_global]; + } } -- cgit v1.2.1 From 2e899c24f9248a06eef7b8cfaed7f5b4a792f7fd Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 13 Jul 2013 12:11:38 -0400 Subject: [feature/oauth] Change name of new method on request PHPBB3-11673 --- phpBB/phpbb/request/interface.php | 2 +- phpBB/phpbb/request/request.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/request/interface.php b/phpBB/phpbb/request/interface.php index 8d472af97a..05f6c54d3f 100644 --- a/phpBB/phpbb/request/interface.php +++ b/phpBB/phpbb/request/interface.php @@ -145,5 +145,5 @@ interface phpbb_request_interface * * @return array The original array of the requested super global. */ - public function original_global_values($super_global = phpbb_request_interface::REQUEST); + public function get_super_global($super_global = phpbb_request_interface::REQUEST); } diff --git a/phpBB/phpbb/request/request.php b/phpBB/phpbb/request/request.php index a4e9a2c2b3..ed2e8e2200 100644 --- a/phpBB/phpbb/request/request.php +++ b/phpBB/phpbb/request/request.php @@ -416,7 +416,7 @@ class phpbb_request implements phpbb_request_interface /** * {@inheritdoc} */ - public function original_global_values($super_global = phpbb_request_interface::REQUEST) + public function get_super_global($super_global = phpbb_request_interface::REQUEST) { return $this->input[$super_global]; } -- cgit v1.2.1 From 93f7ed4fb55daf3ca06957f4374cb827db06432c Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 13 Jul 2013 13:08:37 -0400 Subject: [feature/oauth] Continue work on OAuth login PHPBB3-11673 --- phpBB/config/auth_providers.yml | 1 + phpBB/includes/auth/provider/oauth.php | 51 +++++++++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 7 deletions(-) (limited to 'phpBB') diff --git a/phpBB/config/auth_providers.yml b/phpBB/config/auth_providers.yml index 4d402e71f2..78c799ffb1 100644 --- a/phpBB/config/auth_providers.yml +++ b/phpBB/config/auth_providers.yml @@ -42,5 +42,6 @@ services: - @config - @request - @user + - @cache.driver tags: - { name: auth.provider } diff --git a/phpBB/includes/auth/provider/oauth.php b/phpBB/includes/auth/provider/oauth.php index cbb1d99004..4cf9749b36 100644 --- a/phpBB/includes/auth/provider/oauth.php +++ b/phpBB/includes/auth/provider/oauth.php @@ -25,20 +25,57 @@ use OAuth\Common\Http\Uri\Uri; */ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base { + /** + * Database driver + * + * @var phpbb_db_driver + */ + protected $db; + + /** + * phpBB config + * + * @var phpbb_config + */ + protected $config; + + /** + * phpBB request object + * + * @var phpbb_request + */ + protected $request; + + /** + * phpBB user + * + * @var phpbb_user + */ + protected $user; + + /** + * Cache driver. + * + * @var phpbb_cache_driver_interface + */ + protected $driver; + /** * OAuth Authentication Constructor * - * @param phpbb_db_driver $db - * @param phpbb_config $config - * @param phpbb_request $request - * @param phpbb_user $user + * @param phpbb_db_driver $db + * @param phpbb_config $config + * @param phpbb_request $request + * @param phpbb_user $user + * @param phpbb_cache_driver_interface $driver */ - public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_request $request, phpbb_user $user) + public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_request $request, phpbb_user $user, phpbb_cache_driver_interface $driver) { $this->db = $db; $this->config = $config; $this->request = $request; $this->user = $user; + $this->driver = $driver; } /** @@ -72,11 +109,11 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base $service_factory = new \OAuth\ServiceFactory(); $uri_factory = new \OAuth\Common\Http\Uri\UriFactory(); - $current_uri = $uri_factory->createFromSuperGlobalArray((array)$_SERVER); + $current_uri = $uri_factory->createFromSuperGlobalArray($this->request->get_super_global(phpbb_request_interface::SERVER)); $current_uri->setQuery(''); // In-memory storage - $storage = new Memory(); + $storage = new phpbb_auth_oauth_token_storage($this->driver); // Setup the credentials for the requests $credentials = new Credentials( -- cgit v1.2.1 From aa12f6afc52b1b536068512487b0b95690786f22 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 13 Jul 2013 13:43:12 -0400 Subject: [feature/oauth] More work on login PHPBB3-11673 --- phpBB/includes/auth/provider/oauth.php | 95 +++++++++++++++++++++++++--------- 1 file changed, 70 insertions(+), 25 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/auth/provider/oauth.php b/phpBB/includes/auth/provider/oauth.php index 4cf9749b36..cdfcace5b2 100644 --- a/phpBB/includes/auth/provider/oauth.php +++ b/phpBB/includes/auth/provider/oauth.php @@ -60,6 +60,20 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base */ protected $driver; + /** + * Cached service once it has been created + * + * @var \OAuth\Common\Service\ServiceInterface|null + */ + protected $service; + + /** + * Cached current uri object + * + * @var \OAuth\Common\Http\Uri\UriInterface|null + */ + protected $current_uri; + /** * OAuth Authentication Constructor * @@ -84,8 +98,8 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base public function login($username, $password) { // Requst the name of the OAuth service - $service = $this->request->variable('oauth_service', '', false, phpbb_request_interface::POST); - if ($service === '') + $service_name = $this->request->variable('oauth_service', '', false, phpbb_request_interface::POST); + if ($service_name === '') { return array( 'status' => LOGIN_ERROR_EXTERNAL_AUTH, @@ -94,8 +108,56 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base ); } + if ($this->request->is_set('code', phpbb_request_interface::GET)) + { + // Second pass: request access token, authenticate with phpBB + } else { + // First pass: get authorization uri, redirect to service + } + } + + /** + * + */ + protected function get_service_credentials($service_name) + { + return array( + 'key' => $this->config['auth_oauth_' . $service_name . '_key'], + 'secret' => $this->config['auth_oauth_' . $service_name . '_secret'], + ); + } + + protected function get_current_uri() + { + if ($this->current_uri) + { + return $this->current_uri; + } + + $uri_factory = new \OAuth\Common\Http\Uri\UriFactory(); + $current_uri = $uri_factory->createFromSuperGlobalArray($this->request->get_super_global(phpbb_request_interface::SERVER)); + $current_uri->setQuery(''); + + $this->current_uri = $current_uri; + return $current_uri; + } + + /** + * Returns the cached service object or creates a new one + * + * @param string $service_name The name of the service + * @param array $scope The scope of the request against the api. + * @return \OAuth\Common\Service\ServiceInterface + */ + protected function get_service($service_name, array $scopes = array()) + { + if ($this->service) + { + return $this->service; + } + // Get the service credentials for the given service - $service_credentials = $this->get_credentials($service); + $service_credentials = $this->get_credentials($service_name); // Check that the service has settings if ($service_credentials['key'] == false || $service_credentials['secret'] == false) @@ -107,14 +169,10 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base ); } - $service_factory = new \OAuth\ServiceFactory(); - $uri_factory = new \OAuth\Common\Http\Uri\UriFactory(); - $current_uri = $uri_factory->createFromSuperGlobalArray($this->request->get_super_global(phpbb_request_interface::SERVER)); - $current_uri->setQuery(''); - - // In-memory storage $storage = new phpbb_auth_oauth_token_storage($this->driver); + $current_uri = $this->get_current_uri(); + // Setup the credentials for the requests $credentials = new Credentials( $service_credentials['key'], @@ -122,22 +180,9 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base $current_uri->getAbsoluteUri() ); - if ($this->request->is_set('code', phpbb_request_interface::GET)) - { - // Second pass: request access token, authenticate with phpBB - } else { - // First pass: get authorization uri, redirect to service - } - } + $service_factory = new \OAuth\ServiceFactory(); + $this->service = $service_factory->createService($service_name, $credentials, $storage, $scopes); - /** - * - */ - protected function get_service_credentials($service) - { - return array( - 'key' => $this->config['auth_oauth_' . $service . '_key'], - 'secret' => $this->config['auth_oauth_' . $service . '_secret'], - ); + return $this->service; } } -- cgit v1.2.1 From 37f099b014ea34378096c50cf898c060bd3f0d42 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 13 Jul 2013 13:50:06 -0400 Subject: [feature/oauth] Document and rearrange methods PHPBB3-11673 --- phpBB/includes/auth/provider/oauth.php | 49 +++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 16 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/auth/provider/oauth.php b/phpBB/includes/auth/provider/oauth.php index cdfcace5b2..267105e6b6 100644 --- a/phpBB/includes/auth/provider/oauth.php +++ b/phpBB/includes/auth/provider/oauth.php @@ -108,6 +108,19 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base ); } + // Get the service credentials for the given service + $service_credentials = $this->get_credentials($service_name); + + // Check that the service has settings + if ($service_credentials['key'] == false || $service_credentials['secret'] == false) + { + return array( + 'status' => LOGIN_ERROR_EXTERNAL_AUTH, + 'error_msg' => 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE', + 'user_row' => array('user_id' => ANONYMOUS), + ); + } + if ($this->request->is_set('code', phpbb_request_interface::GET)) { // Second pass: request access token, authenticate with phpBB @@ -117,7 +130,16 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base } /** + * Returns an array containing the service credentials belonging to requested + * service. * + * @param string $service_name The name of the service + * @return array An array containing the 'key' and the 'secret' of the + * service in the form: + * array( + * 'key' => string + * 'secret' => string + * ) */ protected function get_service_credentials($service_name) { @@ -127,6 +149,12 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base ); } + /** + * Returns the cached current_uri object or creates and caches it if it is + * not already created + * + * @return \OAuth\Common\Http\Uri\UriInterface + */ protected function get_current_uri() { if ($this->current_uri) @@ -145,30 +173,19 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base /** * Returns the cached service object or creates a new one * - * @param string $service_name The name of the service - * @param array $scope The scope of the request against the api. + * @param string $service_name The name of the service + * @param array $service_credentials {@see phpbb_auth_provider_oauth::get_service_credentials} + * @param array $scope The scope of the request against + * the api. * @return \OAuth\Common\Service\ServiceInterface */ - protected function get_service($service_name, array $scopes = array()) + protected function get_service($service_name, array $service_credentials, array $scopes = array()) { if ($this->service) { return $this->service; } - // Get the service credentials for the given service - $service_credentials = $this->get_credentials($service_name); - - // Check that the service has settings - if ($service_credentials['key'] == false || $service_credentials['secret'] == false) - { - return array( - 'status' => LOGIN_ERROR_EXTERNAL_AUTH, - 'error_msg' => 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - $storage = new phpbb_auth_oauth_token_storage($this->driver); $current_uri = $this->get_current_uri(); -- cgit v1.2.1 From 24bf333e161332ddd589831228e35ad9eb1e8f18 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 13 Jul 2013 16:51:38 -0400 Subject: [feature/oauth] Use DB for OAuth token storage PHPBB3-11673 --- phpBB/config/auth_providers.yml | 1 - phpBB/develop/create_schema_files.php | 9 +++++ phpBB/includes/auth/oauth/token_storage.php | 18 +++++++--- phpBB/includes/auth/provider/oauth.php | 13 ++----- .../db/migration/data/310/auth_provider_oauth.php | 42 ++++++++++++++++++++++ 5 files changed, 66 insertions(+), 17 deletions(-) create mode 100644 phpBB/includes/db/migration/data/310/auth_provider_oauth.php (limited to 'phpBB') diff --git a/phpBB/config/auth_providers.yml b/phpBB/config/auth_providers.yml index 78c799ffb1..4d402e71f2 100644 --- a/phpBB/config/auth_providers.yml +++ b/phpBB/config/auth_providers.yml @@ -42,6 +42,5 @@ services: - @config - @request - @user - - @cache.driver tags: - { name: auth.provider } diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 316fbe19e6..f3eeb31c28 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -923,6 +923,15 @@ function get_schema_struct() ), ); + $schemda_data['auth_provider_oauth'] = array( + 'COLUMNS' => array( + 'user_id' => array('UINT', 0), // phpbb_users.user_id + 'oauth_provider' => array('VCHAR'), // Name of the OAuth provider + 'oauth_token' => array('TEXT_UNI'), // Serialized token + ), + 'PRIMARY_KEY' => array('user_id', 'oauth_provider'), + ); + $schema_data['phpbb_banlist'] = array( 'COLUMNS' => array( 'ban_id' => array('UINT', NULL, 'auto_increment'), diff --git a/phpBB/includes/auth/oauth/token_storage.php b/phpBB/includes/auth/oauth/token_storage.php index 2d3c58d25a..b658333900 100644 --- a/phpBB/includes/auth/oauth/token_storage.php +++ b/phpBB/includes/auth/oauth/token_storage.php @@ -28,9 +28,16 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface /** * Cache driver. * - * @var phpbb_cache_driver_interface + * @var phpbb_db_driver */ - protected $driver; + protected $db; + + /** + * Name of the OAuth provider + * + * @var string + */ + protected $service_name; /** * @var object|TokenInterface @@ -40,11 +47,12 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface /** * Creates token storage for phpBB. * - * @param phpbb_cache_driver_interface $driver The cache driver + * @param phpbb_db_driver $db */ - public function __construct(phpbb_cache_driver_interface $driver) + public function __construct(phpbb_db_driver $db, $service_name) { - $this->driver = $driver; + $this->db = $db; + $this->service_name = $service_name; } /** diff --git a/phpBB/includes/auth/provider/oauth.php b/phpBB/includes/auth/provider/oauth.php index 267105e6b6..55a12211d6 100644 --- a/phpBB/includes/auth/provider/oauth.php +++ b/phpBB/includes/auth/provider/oauth.php @@ -53,13 +53,6 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base */ protected $user; - /** - * Cache driver. - * - * @var phpbb_cache_driver_interface - */ - protected $driver; - /** * Cached service once it has been created * @@ -81,15 +74,13 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base * @param phpbb_config $config * @param phpbb_request $request * @param phpbb_user $user - * @param phpbb_cache_driver_interface $driver */ - public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_request $request, phpbb_user $user, phpbb_cache_driver_interface $driver) + public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_request $request, phpbb_user $user) { $this->db = $db; $this->config = $config; $this->request = $request; $this->user = $user; - $this->driver = $driver; } /** @@ -186,7 +177,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base return $this->service; } - $storage = new phpbb_auth_oauth_token_storage($this->driver); + $storage = new phpbb_auth_oauth_token_storage($this->db, $service_name); $current_uri = $this->get_current_uri(); diff --git a/phpBB/includes/db/migration/data/310/auth_provider_oauth.php b/phpBB/includes/db/migration/data/310/auth_provider_oauth.php new file mode 100644 index 0000000000..6239cf97bc --- /dev/null +++ b/phpBB/includes/db/migration/data/310/auth_provider_oauth.php @@ -0,0 +1,42 @@ +db_tools->sql_table_exists($this->table_prefix . 'auth_provider_oauth'); + } + + public function update_schema() + { + return array( + 'add_tables' => array( + $this->table_prefix . 'auth_provider_oauth' => array( + 'COLUMNS' => array( + 'user_id' => array('UINT', 0), // phpbb_users.user_id + 'oauth_provider' => array('VCHAR'), // Name of the OAuth provider + 'oauth_token' => array('TEXT_UNI'), // Serialized token + ), + 'PRIMARY_KEY' => array('user_id', 'oauth_provider'), + ), + ), + + ); + } + + public function revert_schema() + { + return array( + 'drop_tables' => array( + $this->table_prefix . 'auth_provider_oauth', + ), + ); + } +} -- cgit v1.2.1 From 02921f4b23fd2fa3efc9eddedfe7bfd6d3347297 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 13 Jul 2013 17:31:41 -0400 Subject: [feature/oauth] Have token storage use DB PHPBB3-11673 --- phpBB/includes/auth/oauth/token_storage.php | 77 +++++++++++++++++++++++++---- 1 file changed, 67 insertions(+), 10 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/auth/oauth/token_storage.php b/phpBB/includes/auth/oauth/token_storage.php index b658333900..4bf52e2ced 100644 --- a/phpBB/includes/auth/oauth/token_storage.php +++ b/phpBB/includes/auth/oauth/token_storage.php @@ -15,8 +15,11 @@ if (!defined('IN_PHPBB')) exit; } -use OAuth\Common\Storage\TokenStorageInterface; + use OAuth\Common\Token\TokenInterface; +use OAuth\Common\Storage\TokenStorageInterface; +use OAuth\Common\Storage\Exception\StorageException; +use OAuth\Common\Storage\Exception\TokenNotFoundException; /** * OAuth storage wrapper for phpbb's cache @@ -32,6 +35,13 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface */ protected $db; + /** + * phpBB user + * + * @var phpbb_user + */ + protected $user; + /** * Name of the OAuth provider * @@ -48,10 +58,13 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface * Creates token storage for phpBB. * * @param phpbb_db_driver $db + * @param phpbb_user $user + * @param string $service_name */ - public function __construct(phpbb_db_driver $db, $service_name) + public function __construct(phpbb_db_driver $db, phpbb_user $user, $service_name) { $this->db = $db; + $this->user = $user; $this->service_name = $service_name; } @@ -64,9 +77,31 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface return $this->token; } - // TODO: check to see if the token is cached + $sql = 'SELECT oauth_token FROM ' . AUTH_PROVIDER_OAUTH . + $db->sql_build_array('SELECT', array( + 'user_id' => $this->user->data['user_id'], + 'oauth_provider' => $this->service_name, + )); + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if (!$row) + { + throw new TokenNotFoundException('Token not stored'); + } + + $token = unserialize($row['oauth_token']); - throw new TokenNotFoundException('Token not stored'); + // Ensure that the token was serialized/unserialized correctly + if (!($token instanceof TokenInterface)) + { + $this->clearToken(); + throw new TokenNotFoundException('Token not stored correctly'); + } + + $this->cachedToken = $token; + return $token; } /** @@ -75,7 +110,13 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface public function storeAccessToken(TokenInterface $token) { $this->cachedToken = $token; - // TODO: actually store the token + + $sql = 'INSERT INTO ' . AUTH_PROVIDER_OAUTH . ' ' . $this->db->sql_build_array('INSERT', array( + 'user_id' => $this->user->data['user_id'], + 'oauth_provider' => $this->service_name, + 'oauth_token' => serialize($token), + )); + $this->db->sql_query($sql); } /** @@ -84,11 +125,24 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface public function hasAccessToken() { if( $this->cachedToken ) { - return true; - } + return true; + } - // TODO: check cache for token - return false; + $sql = 'SELECT oauth_token FROM ' . AUTH_PROVIDER_OAUTH . + $db->sql_build_array('SELECT', array( + 'user_id' => $this->user->data['user_id'], + 'oauth_provider' => $this->service_name, + )); + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if (!$row) + { + return false; + } + + return true; } /** @@ -97,6 +151,9 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface public function clearToken() { $this->cachedToken = null; - // TODO: clear cache of the token + + $sql = 'DELETE FROM ' . AUTH_PROVIDER_OAUTH . 'WHERE user_id = ' . $this->user->data['user_id'] . + ' AND oauth_provider = ' . $this->db->sql_escape($this->oauth_provider); + $this->db->sql_query($sql); } } -- cgit v1.2.1 From b22b076a9972e0bd41551c314f4fea4e938d1d58 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 13 Jul 2013 17:32:27 -0400 Subject: [feature/oauth] Update invocation of method in OAuth PHPBB3-11673 --- phpBB/includes/auth/provider/oauth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/includes/auth/provider/oauth.php b/phpBB/includes/auth/provider/oauth.php index 55a12211d6..ee18c0f60d 100644 --- a/phpBB/includes/auth/provider/oauth.php +++ b/phpBB/includes/auth/provider/oauth.php @@ -177,7 +177,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base return $this->service; } - $storage = new phpbb_auth_oauth_token_storage($this->db, $service_name); + $storage = new phpbb_auth_oauth_token_storage($this->db, $this->user, $service_name); $current_uri = $this->get_current_uri(); -- cgit v1.2.1 From 69e158865560bba4264646faa0799aa6e457c6d0 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 13 Jul 2013 17:59:04 -0400 Subject: [feature/oauth] Store anonymous user by session id PHPBB3-9734 --- phpBB/develop/create_schema_files.php | 6 +++++- phpBB/includes/db/migration/data/310/auth_provider_oauth.php | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index f3eeb31c28..c7d3cc4106 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -926,10 +926,14 @@ function get_schema_struct() $schemda_data['auth_provider_oauth'] = array( 'COLUMNS' => array( 'user_id' => array('UINT', 0), // phpbb_users.user_id + 'session_id' => array('CHAR:32', ''), // phpbb_sessions.session_id used only when user_id not set 'oauth_provider' => array('VCHAR'), // Name of the OAuth provider 'oauth_token' => array('TEXT_UNI'), // Serialized token ), - 'PRIMARY_KEY' => array('user_id', 'oauth_provider'), + 'KEYS' => array( + 'user_id' => array('INDEX', 'user_id'), + 'oauth_provider' => array('INDEX', 'oauth_provider'), + ), ); $schema_data['phpbb_banlist'] = array( diff --git a/phpBB/includes/db/migration/data/310/auth_provider_oauth.php b/phpBB/includes/db/migration/data/310/auth_provider_oauth.php index 6239cf97bc..92da42ba31 100644 --- a/phpBB/includes/db/migration/data/310/auth_provider_oauth.php +++ b/phpBB/includes/db/migration/data/310/auth_provider_oauth.php @@ -21,13 +21,16 @@ class phpbb_db_migration_data_310_auth_provider_oauth extends phpbb_db_migration $this->table_prefix . 'auth_provider_oauth' => array( 'COLUMNS' => array( 'user_id' => array('UINT', 0), // phpbb_users.user_id + 'session_id' => array('CHAR:32', ''), // phpbb_sessions.session_id used only when user_id not set 'oauth_provider' => array('VCHAR'), // Name of the OAuth provider 'oauth_token' => array('TEXT_UNI'), // Serialized token ), - 'PRIMARY_KEY' => array('user_id', 'oauth_provider'), + 'KEYS' => array( + 'user_id' => array('INDEX', 'user_id'), + 'oauth_provider' => array('INDEX', 'oauth_provider'), + ), ), ), - ); } -- cgit v1.2.1 From 5942eac5dac51e9f70a1f175a480316975fb3ac9 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 13 Jul 2013 18:17:03 -0400 Subject: [feature/oauth] Pass table in constructor PHPBB3-11673 --- phpBB/config/auth_providers.yml | 1 + phpBB/config/tables.yml | 1 + phpBB/includes/auth/oauth/token_storage.php | 34 +++++++++++++++++++---------- phpBB/includes/auth/provider/oauth.php | 21 +++++++++++++----- 4 files changed, 39 insertions(+), 18 deletions(-) (limited to 'phpBB') diff --git a/phpBB/config/auth_providers.yml b/phpBB/config/auth_providers.yml index 4d402e71f2..ead540c953 100644 --- a/phpBB/config/auth_providers.yml +++ b/phpBB/config/auth_providers.yml @@ -42,5 +42,6 @@ services: - @config - @request - @user + - %tables.auth_provider_oauth% tags: - { name: auth.provider } diff --git a/phpBB/config/tables.yml b/phpBB/config/tables.yml index fdb448f4e0..48098ba8c2 100644 --- a/phpBB/config/tables.yml +++ b/phpBB/config/tables.yml @@ -1,4 +1,5 @@ parameters: + tables.auth_provider_oauth: %core.table_prefix%auth_provider_oauth tables.config: %core.table_prefix%config tables.config_text: %core.table_prefix%config_text tables.ext: %core.table_prefix%ext diff --git a/phpBB/includes/auth/oauth/token_storage.php b/phpBB/includes/auth/oauth/token_storage.php index 4bf52e2ced..90185e5f5a 100644 --- a/phpBB/includes/auth/oauth/token_storage.php +++ b/phpBB/includes/auth/oauth/token_storage.php @@ -49,6 +49,13 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface */ protected $service_name; + /** + * OAuth token table + * + * @var string + */ + protected $auth_provider_oauth_table; + /** * @var object|TokenInterface */ @@ -57,15 +64,17 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface /** * Creates token storage for phpBB. * - * @param phpbb_db_driver $db - * @param phpbb_user $user - * @param string $service_name + * @param phpbb_db_driver $db + * @param phpbb_user $user + * @param string $service_name + * @param string $auth_provider_oauth_table */ - public function __construct(phpbb_db_driver $db, phpbb_user $user, $service_name) + public function __construct(phpbb_db_driver $db, phpbb_user $user, $service_name, $auth_provider_oauth_table) { $this->db = $db; $this->user = $user; $this->service_name = $service_name; + $this->auth_provider_oauth_table = $auth_provider_oauth_table; } /** @@ -77,7 +86,7 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface return $this->token; } - $sql = 'SELECT oauth_token FROM ' . AUTH_PROVIDER_OAUTH . + $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . $db->sql_build_array('SELECT', array( 'user_id' => $this->user->data['user_id'], 'oauth_provider' => $this->service_name, @@ -111,11 +120,12 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface { $this->cachedToken = $token; - $sql = 'INSERT INTO ' . AUTH_PROVIDER_OAUTH . ' ' . $this->db->sql_build_array('INSERT', array( - 'user_id' => $this->user->data['user_id'], - 'oauth_provider' => $this->service_name, - 'oauth_token' => serialize($token), - )); + $sql = 'INSERT INTO ' . $this->auth_provider_oauth_table . ' ' . + $this->db->sql_build_array('INSERT', array( + 'user_id' => $this->user->data['user_id'], + 'oauth_provider' => $this->service_name, + 'oauth_token' => serialize($token), + )); $this->db->sql_query($sql); } @@ -128,7 +138,7 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface return true; } - $sql = 'SELECT oauth_token FROM ' . AUTH_PROVIDER_OAUTH . + $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . $db->sql_build_array('SELECT', array( 'user_id' => $this->user->data['user_id'], 'oauth_provider' => $this->service_name, @@ -152,7 +162,7 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface { $this->cachedToken = null; - $sql = 'DELETE FROM ' . AUTH_PROVIDER_OAUTH . 'WHERE user_id = ' . $this->user->data['user_id'] . + $sql = 'DELETE FROM ' . $this->auth_provider_oauth_table . 'WHERE user_id = ' . $this->user->data['user_id'] . ' AND oauth_provider = ' . $this->db->sql_escape($this->oauth_provider); $this->db->sql_query($sql); } diff --git a/phpBB/includes/auth/provider/oauth.php b/phpBB/includes/auth/provider/oauth.php index ee18c0f60d..c7f60c5ae4 100644 --- a/phpBB/includes/auth/provider/oauth.php +++ b/phpBB/includes/auth/provider/oauth.php @@ -53,6 +53,13 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base */ protected $user; + /** + * OAuth token table + * + * @var string + */ + protected $auth_provider_oauth_table; + /** * Cached service once it has been created * @@ -70,17 +77,19 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base /** * OAuth Authentication Constructor * - * @param phpbb_db_driver $db - * @param phpbb_config $config - * @param phpbb_request $request - * @param phpbb_user $user + * @param phpbb_db_driver $db + * @param phpbb_config $config + * @param phpbb_request $request + * @param phpbb_user $user + * @param string $auth_provider_oauth_table */ - public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_request $request, phpbb_user $user) + public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_request $request, phpbb_user $user, $auth_provider_oauth_table) { $this->db = $db; $this->config = $config; $this->request = $request; $this->user = $user; + $this->auth_provider_oauth_table = $auth_provider_oauth_table; } /** @@ -177,7 +186,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base return $this->service; } - $storage = new phpbb_auth_oauth_token_storage($this->db, $this->user, $service_name); + $storage = new phpbb_auth_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_table); $current_uri = $this->get_current_uri(); -- cgit v1.2.1 From 68a80f8ea8d61a8ad60f046a2ef68124d2abc801 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 13 Jul 2013 18:20:49 -0400 Subject: [feature/oauth] Fix typo PHPBB3-11673 --- phpBB/includes/auth/oauth/token_storage.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/auth/oauth/token_storage.php b/phpBB/includes/auth/oauth/token_storage.php index 90185e5f5a..c3d560cc79 100644 --- a/phpBB/includes/auth/oauth/token_storage.php +++ b/phpBB/includes/auth/oauth/token_storage.php @@ -87,7 +87,7 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface } $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . - $db->sql_build_array('SELECT', array( + $this->db->sql_build_array('SELECT', array( 'user_id' => $this->user->data['user_id'], 'oauth_provider' => $this->service_name, )); @@ -139,7 +139,7 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface } $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . - $db->sql_build_array('SELECT', array( + $this->db->sql_build_array('SELECT', array( 'user_id' => $this->user->data['user_id'], 'oauth_provider' => $this->service_name, )); -- cgit v1.2.1 From 3c8187c277446ac07e5ff08c05a6e535f401ae2d Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 13 Jul 2013 18:30:41 -0400 Subject: [feature/oauth] Have array of services not just one in oauth PHPBB3-11673 --- phpBB/includes/auth/provider/oauth.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/auth/provider/oauth.php b/phpBB/includes/auth/provider/oauth.php index c7f60c5ae4..c59c573c52 100644 --- a/phpBB/includes/auth/provider/oauth.php +++ b/phpBB/includes/auth/provider/oauth.php @@ -61,11 +61,11 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base protected $auth_provider_oauth_table; /** - * Cached service once it has been created + * Cached services once they has been created * - * @var \OAuth\Common\Service\ServiceInterface|null + * @var array Contains \OAuth\Common\Service\ServiceInterface or null */ - protected $service; + protected $services; /** * Cached current uri object @@ -90,6 +90,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base $this->request = $request; $this->user = $user; $this->auth_provider_oauth_table = $auth_provider_oauth_table; + $this->services = array(); } /** @@ -181,9 +182,9 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base */ protected function get_service($service_name, array $service_credentials, array $scopes = array()) { - if ($this->service) + if ($this->services[$service_name]) { - return $this->service; + return $this->services[$service_name]; } $storage = new phpbb_auth_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_table); @@ -198,8 +199,8 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base ); $service_factory = new \OAuth\ServiceFactory(); - $this->service = $service_factory->createService($service_name, $credentials, $storage, $scopes); + $this->service[$service_name] = $service_factory->createService($service_name, $credentials, $storage, $scopes); - return $this->service; + return $this->service[$service_name]; } } -- cgit v1.2.1 From 9619a9a16f68edddb052d5848f96f4e603ddc299 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 13 Jul 2013 23:00:43 -0400 Subject: [feature/oauth] Anonymous user does not depend on user_id in token PHPBB3-11673 --- phpBB/includes/auth/oauth/token_storage.php | 66 +++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 18 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/auth/oauth/token_storage.php b/phpBB/includes/auth/oauth/token_storage.php index c3d560cc79..b35a5c6586 100644 --- a/phpBB/includes/auth/oauth/token_storage.php +++ b/phpBB/includes/auth/oauth/token_storage.php @@ -86,17 +86,25 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface return $this->token; } - $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . - $this->db->sql_build_array('SELECT', array( - 'user_id' => $this->user->data['user_id'], - 'oauth_provider' => $this->service_name, - )); + $data = array( + 'user_id' => $this->user->data['user_id'], + 'oauth_provider' => $this->service_name, + ); + + if ($this->user->data['user_id'] == ANONYMOUS) + { + $data['session_id'] = $this->user->data['session_id']; + } + + $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . ' + WHERE ' . $this->db->sql_build_array('SELECT', $data); $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); if (!$row) { + // TODO: translate throw new TokenNotFoundException('Token not stored'); } @@ -106,6 +114,7 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface if (!($token instanceof TokenInterface)) { $this->clearToken(); + // TODO: translate throw new TokenNotFoundException('Token not stored correctly'); } @@ -120,12 +129,19 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface { $this->cachedToken = $token; - $sql = 'INSERT INTO ' . $this->auth_provider_oauth_table . ' ' . - $this->db->sql_build_array('INSERT', array( - 'user_id' => $this->user->data['user_id'], - 'oauth_provider' => $this->service_name, - 'oauth_token' => serialize($token), - )); + $data = array( + 'user_id' => $this->user->data['user_id'], + 'oauth_provider' => $this->service_name, + 'oauth_token' => serialize($token), + ); + + if ($this->user->data['user_id'] == ANONYMOUS) + { + $data['session_id'] = $this->user->data['session_id']; + } + + $sql = 'INSERT INTO ' . $this->auth_provider_oauth_table . ' + WHERE ' . $this->db->sql_build_array('INSERT', $data); $this->db->sql_query($sql); } @@ -138,11 +154,18 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface return true; } - $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . - $this->db->sql_build_array('SELECT', array( - 'user_id' => $this->user->data['user_id'], - 'oauth_provider' => $this->service_name, - )); + $data = array( + 'user_id' => $this->user->data['user_id'], + 'oauth_provider' => $this->service_name, + ); + + if ($this->user->data['user_id'] == ANONYMOUS) + { + $data['session_id'] = $this->user->data['session_id']; + } + + $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . ' + WHERE ' . $this->db->sql_build_array('SELECT', $data); $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); @@ -162,8 +185,15 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface { $this->cachedToken = null; - $sql = 'DELETE FROM ' . $this->auth_provider_oauth_table . 'WHERE user_id = ' . $this->user->data['user_id'] . - ' AND oauth_provider = ' . $this->db->sql_escape($this->oauth_provider); + $sql = 'DELETE FROM ' . $this->auth_provider_oauth_table . ' + WHERE user_id = ' . $this->user->data['user_id'] . ' + AND oauth_provider = ' . $this->db->sql_escape($this->oauth_provider); + + if ($this->user->data['user_id'] == ANONYMOUS) + { + $sql .= ' AND session_id = ' . $this->user->data['session_id']; + } + $this->db->sql_query($sql); } } -- cgit v1.2.1 From 6e73ccd00f363917de2914de3b8c75d296cdb355 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 13 Jul 2013 23:26:14 -0400 Subject: [feature/oauth] Function to update user_id of a token PHPBB3-9734 --- phpBB/includes/auth/oauth/token_storage.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'phpBB') diff --git a/phpBB/includes/auth/oauth/token_storage.php b/phpBB/includes/auth/oauth/token_storage.php index b35a5c6586..fcc277053c 100644 --- a/phpBB/includes/auth/oauth/token_storage.php +++ b/phpBB/includes/auth/oauth/token_storage.php @@ -196,4 +196,25 @@ class phpbb_auth_oauth_token_storage implements TokenStorageInterface $this->db->sql_query($sql); } + + /** + * Updates the user_id field in the database assosciated with the token + * + * @param int $user_id + */ + public function set_user_id($user_id) + { + if (!$this->cachedToken) + { + return; + } + + $sql = 'UPDATE ' . $this->auth_provider_oauth_table . ' + SET ' . $db->sql_build_array('UPDATE', array( + 'user_id' => (int) $user_id + )) . ' + WHERE user_id = ' . $this->user->data['user_id'] . ' + AND session_id = ' . $this->user->data['session_id']; + $this->db->sql_query($sql); + } } -- cgit v1.2.1 From a7bfe5eeeb1250c96fb2ddb1ee19f1babe72fe3d Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 13 Jul 2013 23:47:16 -0400 Subject: [feature/oauth] Changes to oauth PHPBB3-11673 --- phpBB/includes/auth/provider/oauth.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/auth/provider/oauth.php b/phpBB/includes/auth/provider/oauth.php index c59c573c52..d405bb77b1 100644 --- a/phpBB/includes/auth/provider/oauth.php +++ b/phpBB/includes/auth/provider/oauth.php @@ -104,6 +104,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base { return array( 'status' => LOGIN_ERROR_EXTERNAL_AUTH, + // TODO: change error message 'error_msg' => 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE', 'user_row' => array('user_id' => ANONYMOUS), ); @@ -117,11 +118,14 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base { return array( 'status' => LOGIN_ERROR_EXTERNAL_AUTH, + // TODO: change error message 'error_msg' => 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE', 'user_row' => array('user_id' => ANONYMOUS), ); } + $storage = new phpbb_auth_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_table); + if ($this->request->is_set('code', phpbb_request_interface::GET)) { // Second pass: request access token, authenticate with phpBB @@ -175,20 +179,19 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base * Returns the cached service object or creates a new one * * @param string $service_name The name of the service + * @param phpbb_auth_oauth_token_storage $storage * @param array $service_credentials {@see phpbb_auth_provider_oauth::get_service_credentials} * @param array $scope The scope of the request against * the api. * @return \OAuth\Common\Service\ServiceInterface */ - protected function get_service($service_name, array $service_credentials, array $scopes = array()) + protected function get_service($service_name, phpbb_auth_oauth_token_storage $storage, array $service_credentials, array $scopes = array()) { if ($this->services[$service_name]) { return $this->services[$service_name]; } - $storage = new phpbb_auth_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_table); - $current_uri = $this->get_current_uri(); // Setup the credentials for the requests -- cgit v1.2.1 From e600596602d1fed7eedda02c848db9012fda43fa Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sun, 14 Jul 2013 11:38:19 -0400 Subject: [feature/oauth] Scopes/path part one PHPBB3-11673 --- phpBB/includes/auth/provider/oauth.php | 61 ++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/auth/provider/oauth.php b/phpBB/includes/auth/provider/oauth.php index d405bb77b1..79a5988526 100644 --- a/phpBB/includes/auth/provider/oauth.php +++ b/phpBB/includes/auth/provider/oauth.php @@ -125,12 +125,20 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base } $storage = new phpbb_auth_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_table); + $service = $this->get_service($service_name, $storage, $service_credentials, $this->get_scopes($service_name)); if ($this->request->is_set('code', phpbb_request_interface::GET)) { - // Second pass: request access token, authenticate with phpBB + // This was a callback request from the service provider + $service->requestAccessToken( $_GET['code'] ); + + // Send a request with it + $result = json_decode( $service->request('user/info'), true ); + } else { - // First pass: get authorization uri, redirect to service + $url = $service->getAuthorizationUri(); + // TODO: modify $url for the appropriate return points + header('Location: ' . $url); } } @@ -206,4 +214,53 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base return $this->service[$service_name]; } + + /** + * Returns the scopes of the service required for authentication + * + * @param string $service_name + * @return array An array of the scopes required from the service + */ + protected function get_scopes($service_name) + { + $scopes = array(); + + switch ($service_name) + { + case 'GitHub': + $scopes[] = 'user'; + break; + case 'google': + $scopes[] = 'userinfo_email'; + $scopes[] = 'userinfo_profile'; + break; + case 'instagram': + case 'microsoft': + $scopes[] = 'basic'; + break; + case 'linkedin': + $scopes[] = 'r_basicprofile'; + break; + } + + return $scopes; + } + + /** + * Returns the path desired of the service + * + * @param string $service_name + * @return string|UriInterface + */ + protected function get_path($service_name) + { + switch ($service_name) + { + default: + $path = ''; + break; + } + + return $path; + } } -- cgit v1.2.1 From 4b1390ca31949d9de0df3b9038144e882c75a5e7 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sun, 14 Jul 2013 11:48:02 -0400 Subject: [feature/oauth] Pathing information for some services PHPBB3-11673 --- phpBB/includes/auth/provider/oauth.php | 44 +++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/auth/provider/oauth.php b/phpBB/includes/auth/provider/oauth.php index 79a5988526..aeca2a4869 100644 --- a/phpBB/includes/auth/provider/oauth.php +++ b/phpBB/includes/auth/provider/oauth.php @@ -133,8 +133,13 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base $service->requestAccessToken( $_GET['code'] ); // Send a request with it - $result = json_decode( $service->request('user/info'), true ); + $path = $this->get_path($service_name); + if ($path) + { + $result = json_decode( $service->request($path), true ); + } + // Perform authentication } else { $url = $service->getAuthorizationUri(); // TODO: modify $url for the appropriate return points @@ -250,14 +255,47 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base * Returns the path desired of the service * * @param string $service_name - * @return string|UriInterface + * @return string|UriInterface|null A null return means do not + * request additional information. */ protected function get_path($service_name) { switch ($service_name) { + case 'bitly': + case 'tumblr': + $path = 'user/info'; + break; + case 'box': + $path = '/users/me'; + break; + case 'facebook': + $path = '/me'; + break; + case 'FitBit': + $path = 'user/-/profile.json'; + break; + case 'foursquare': + case 'instagram': + $path = 'users/self'; + break; + case 'GitHub': + $path = 'user/emails'; + break; + case 'google': + $path = 'https://www.googleapis.com/oauth2/v1/userinfo'; + break; + case 'linkedin': + $path = '/people/~?format=json'; + break; + case 'soundCloud': + $path = 'me.json'; + break; + case 'twitter': + $path = 'account/verify_credentials.json'; + break; default: - $path = ''; + $path = null; break; } -- cgit v1.2.1 From 1a3880806a453dc4782b9823c2557dc22e9fb6af Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sun, 14 Jul 2013 13:23:09 -0400 Subject: [feature/oauth] Move OAuth to /phpBB/phpbb PHPBB3-11673 --- phpBB/includes/auth/oauth/token_storage.php | 220 -------------------- phpBB/includes/auth/provider/oauth.php | 304 ---------------------------- phpBB/phpbb/auth/oauth/token_storage.php | 220 ++++++++++++++++++++ phpBB/phpbb/auth/provider/oauth.php | 304 ++++++++++++++++++++++++++++ 4 files changed, 524 insertions(+), 524 deletions(-) delete mode 100644 phpBB/includes/auth/oauth/token_storage.php delete mode 100644 phpBB/includes/auth/provider/oauth.php create mode 100644 phpBB/phpbb/auth/oauth/token_storage.php create mode 100644 phpBB/phpbb/auth/provider/oauth.php (limited to 'phpBB') diff --git a/phpBB/includes/auth/oauth/token_storage.php b/phpBB/includes/auth/oauth/token_storage.php deleted file mode 100644 index fcc277053c..0000000000 --- a/phpBB/includes/auth/oauth/token_storage.php +++ /dev/null @@ -1,220 +0,0 @@ -db = $db; - $this->user = $user; - $this->service_name = $service_name; - $this->auth_provider_oauth_table = $auth_provider_oauth_table; - } - - /** - * {@inheritdoc} - */ - public function retrieveAccessToken() - { - if( $this->cachedToken instanceOf TokenInterface ) { - return $this->token; - } - - $data = array( - 'user_id' => $this->user->data['user_id'], - 'oauth_provider' => $this->service_name, - ); - - if ($this->user->data['user_id'] == ANONYMOUS) - { - $data['session_id'] = $this->user->data['session_id']; - } - - $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . ' - WHERE ' . $this->db->sql_build_array('SELECT', $data); - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if (!$row) - { - // TODO: translate - throw new TokenNotFoundException('Token not stored'); - } - - $token = unserialize($row['oauth_token']); - - // Ensure that the token was serialized/unserialized correctly - if (!($token instanceof TokenInterface)) - { - $this->clearToken(); - // TODO: translate - throw new TokenNotFoundException('Token not stored correctly'); - } - - $this->cachedToken = $token; - return $token; - } - - /** - * {@inheritdoc} - */ - public function storeAccessToken(TokenInterface $token) - { - $this->cachedToken = $token; - - $data = array( - 'user_id' => $this->user->data['user_id'], - 'oauth_provider' => $this->service_name, - 'oauth_token' => serialize($token), - ); - - if ($this->user->data['user_id'] == ANONYMOUS) - { - $data['session_id'] = $this->user->data['session_id']; - } - - $sql = 'INSERT INTO ' . $this->auth_provider_oauth_table . ' - WHERE ' . $this->db->sql_build_array('INSERT', $data); - $this->db->sql_query($sql); - } - - /** - * {@inheritdoc} - */ - public function hasAccessToken() - { - if( $this->cachedToken ) { - return true; - } - - $data = array( - 'user_id' => $this->user->data['user_id'], - 'oauth_provider' => $this->service_name, - ); - - if ($this->user->data['user_id'] == ANONYMOUS) - { - $data['session_id'] = $this->user->data['session_id']; - } - - $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . ' - WHERE ' . $this->db->sql_build_array('SELECT', $data); - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if (!$row) - { - return false; - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function clearToken() - { - $this->cachedToken = null; - - $sql = 'DELETE FROM ' . $this->auth_provider_oauth_table . ' - WHERE user_id = ' . $this->user->data['user_id'] . ' - AND oauth_provider = ' . $this->db->sql_escape($this->oauth_provider); - - if ($this->user->data['user_id'] == ANONYMOUS) - { - $sql .= ' AND session_id = ' . $this->user->data['session_id']; - } - - $this->db->sql_query($sql); - } - - /** - * Updates the user_id field in the database assosciated with the token - * - * @param int $user_id - */ - public function set_user_id($user_id) - { - if (!$this->cachedToken) - { - return; - } - - $sql = 'UPDATE ' . $this->auth_provider_oauth_table . ' - SET ' . $db->sql_build_array('UPDATE', array( - 'user_id' => (int) $user_id - )) . ' - WHERE user_id = ' . $this->user->data['user_id'] . ' - AND session_id = ' . $this->user->data['session_id']; - $this->db->sql_query($sql); - } -} diff --git a/phpBB/includes/auth/provider/oauth.php b/phpBB/includes/auth/provider/oauth.php deleted file mode 100644 index aeca2a4869..0000000000 --- a/phpBB/includes/auth/provider/oauth.php +++ /dev/null @@ -1,304 +0,0 @@ -db = $db; - $this->config = $config; - $this->request = $request; - $this->user = $user; - $this->auth_provider_oauth_table = $auth_provider_oauth_table; - $this->services = array(); - } - - /** - * {@inheritdoc} - */ - public function login($username, $password) - { - // Requst the name of the OAuth service - $service_name = $this->request->variable('oauth_service', '', false, phpbb_request_interface::POST); - if ($service_name === '') - { - return array( - 'status' => LOGIN_ERROR_EXTERNAL_AUTH, - // TODO: change error message - 'error_msg' => 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - // Get the service credentials for the given service - $service_credentials = $this->get_credentials($service_name); - - // Check that the service has settings - if ($service_credentials['key'] == false || $service_credentials['secret'] == false) - { - return array( - 'status' => LOGIN_ERROR_EXTERNAL_AUTH, - // TODO: change error message - 'error_msg' => 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - $storage = new phpbb_auth_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_table); - $service = $this->get_service($service_name, $storage, $service_credentials, $this->get_scopes($service_name)); - - if ($this->request->is_set('code', phpbb_request_interface::GET)) - { - // This was a callback request from the service provider - $service->requestAccessToken( $_GET['code'] ); - - // Send a request with it - $path = $this->get_path($service_name); - if ($path) - { - $result = json_decode( $service->request($path), true ); - } - - // Perform authentication - } else { - $url = $service->getAuthorizationUri(); - // TODO: modify $url for the appropriate return points - header('Location: ' . $url); - } - } - - /** - * Returns an array containing the service credentials belonging to requested - * service. - * - * @param string $service_name The name of the service - * @return array An array containing the 'key' and the 'secret' of the - * service in the form: - * array( - * 'key' => string - * 'secret' => string - * ) - */ - protected function get_service_credentials($service_name) - { - return array( - 'key' => $this->config['auth_oauth_' . $service_name . '_key'], - 'secret' => $this->config['auth_oauth_' . $service_name . '_secret'], - ); - } - - /** - * Returns the cached current_uri object or creates and caches it if it is - * not already created - * - * @return \OAuth\Common\Http\Uri\UriInterface - */ - protected function get_current_uri() - { - if ($this->current_uri) - { - return $this->current_uri; - } - - $uri_factory = new \OAuth\Common\Http\Uri\UriFactory(); - $current_uri = $uri_factory->createFromSuperGlobalArray($this->request->get_super_global(phpbb_request_interface::SERVER)); - $current_uri->setQuery(''); - - $this->current_uri = $current_uri; - return $current_uri; - } - - /** - * Returns the cached service object or creates a new one - * - * @param string $service_name The name of the service - * @param phpbb_auth_oauth_token_storage $storage - * @param array $service_credentials {@see phpbb_auth_provider_oauth::get_service_credentials} - * @param array $scope The scope of the request against - * the api. - * @return \OAuth\Common\Service\ServiceInterface - */ - protected function get_service($service_name, phpbb_auth_oauth_token_storage $storage, array $service_credentials, array $scopes = array()) - { - if ($this->services[$service_name]) - { - return $this->services[$service_name]; - } - - $current_uri = $this->get_current_uri(); - - // Setup the credentials for the requests - $credentials = new Credentials( - $service_credentials['key'], - $service_credentials['secret'], - $current_uri->getAbsoluteUri() - ); - - $service_factory = new \OAuth\ServiceFactory(); - $this->service[$service_name] = $service_factory->createService($service_name, $credentials, $storage, $scopes); - - return $this->service[$service_name]; - } - - /** - * Returns the scopes of the service required for authentication - * - * @param string $service_name - * @return array An array of the scopes required from the service - */ - protected function get_scopes($service_name) - { - $scopes = array(); - - switch ($service_name) - { - case 'GitHub': - $scopes[] = 'user'; - break; - case 'google': - $scopes[] = 'userinfo_email'; - $scopes[] = 'userinfo_profile'; - break; - case 'instagram': - case 'microsoft': - $scopes[] = 'basic'; - break; - case 'linkedin': - $scopes[] = 'r_basicprofile'; - break; - } - - return $scopes; - } - - /** - * Returns the path desired of the service - * - * @param string $service_name - * @return string|UriInterface|null A null return means do not - * request additional information. - */ - protected function get_path($service_name) - { - switch ($service_name) - { - case 'bitly': - case 'tumblr': - $path = 'user/info'; - break; - case 'box': - $path = '/users/me'; - break; - case 'facebook': - $path = '/me'; - break; - case 'FitBit': - $path = 'user/-/profile.json'; - break; - case 'foursquare': - case 'instagram': - $path = 'users/self'; - break; - case 'GitHub': - $path = 'user/emails'; - break; - case 'google': - $path = 'https://www.googleapis.com/oauth2/v1/userinfo'; - break; - case 'linkedin': - $path = '/people/~?format=json'; - break; - case 'soundCloud': - $path = 'me.json'; - break; - case 'twitter': - $path = 'account/verify_credentials.json'; - break; - default: - $path = null; - break; - } - - return $path; - } -} diff --git a/phpBB/phpbb/auth/oauth/token_storage.php b/phpBB/phpbb/auth/oauth/token_storage.php new file mode 100644 index 0000000000..fcc277053c --- /dev/null +++ b/phpBB/phpbb/auth/oauth/token_storage.php @@ -0,0 +1,220 @@ +db = $db; + $this->user = $user; + $this->service_name = $service_name; + $this->auth_provider_oauth_table = $auth_provider_oauth_table; + } + + /** + * {@inheritdoc} + */ + public function retrieveAccessToken() + { + if( $this->cachedToken instanceOf TokenInterface ) { + return $this->token; + } + + $data = array( + 'user_id' => $this->user->data['user_id'], + 'oauth_provider' => $this->service_name, + ); + + if ($this->user->data['user_id'] == ANONYMOUS) + { + $data['session_id'] = $this->user->data['session_id']; + } + + $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . ' + WHERE ' . $this->db->sql_build_array('SELECT', $data); + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if (!$row) + { + // TODO: translate + throw new TokenNotFoundException('Token not stored'); + } + + $token = unserialize($row['oauth_token']); + + // Ensure that the token was serialized/unserialized correctly + if (!($token instanceof TokenInterface)) + { + $this->clearToken(); + // TODO: translate + throw new TokenNotFoundException('Token not stored correctly'); + } + + $this->cachedToken = $token; + return $token; + } + + /** + * {@inheritdoc} + */ + public function storeAccessToken(TokenInterface $token) + { + $this->cachedToken = $token; + + $data = array( + 'user_id' => $this->user->data['user_id'], + 'oauth_provider' => $this->service_name, + 'oauth_token' => serialize($token), + ); + + if ($this->user->data['user_id'] == ANONYMOUS) + { + $data['session_id'] = $this->user->data['session_id']; + } + + $sql = 'INSERT INTO ' . $this->auth_provider_oauth_table . ' + WHERE ' . $this->db->sql_build_array('INSERT', $data); + $this->db->sql_query($sql); + } + + /** + * {@inheritdoc} + */ + public function hasAccessToken() + { + if( $this->cachedToken ) { + return true; + } + + $data = array( + 'user_id' => $this->user->data['user_id'], + 'oauth_provider' => $this->service_name, + ); + + if ($this->user->data['user_id'] == ANONYMOUS) + { + $data['session_id'] = $this->user->data['session_id']; + } + + $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . ' + WHERE ' . $this->db->sql_build_array('SELECT', $data); + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if (!$row) + { + return false; + } + + return true; + } + + /** + * {@inheritdoc} + */ + public function clearToken() + { + $this->cachedToken = null; + + $sql = 'DELETE FROM ' . $this->auth_provider_oauth_table . ' + WHERE user_id = ' . $this->user->data['user_id'] . ' + AND oauth_provider = ' . $this->db->sql_escape($this->oauth_provider); + + if ($this->user->data['user_id'] == ANONYMOUS) + { + $sql .= ' AND session_id = ' . $this->user->data['session_id']; + } + + $this->db->sql_query($sql); + } + + /** + * Updates the user_id field in the database assosciated with the token + * + * @param int $user_id + */ + public function set_user_id($user_id) + { + if (!$this->cachedToken) + { + return; + } + + $sql = 'UPDATE ' . $this->auth_provider_oauth_table . ' + SET ' . $db->sql_build_array('UPDATE', array( + 'user_id' => (int) $user_id + )) . ' + WHERE user_id = ' . $this->user->data['user_id'] . ' + AND session_id = ' . $this->user->data['session_id']; + $this->db->sql_query($sql); + } +} diff --git a/phpBB/phpbb/auth/provider/oauth.php b/phpBB/phpbb/auth/provider/oauth.php new file mode 100644 index 0000000000..aeca2a4869 --- /dev/null +++ b/phpBB/phpbb/auth/provider/oauth.php @@ -0,0 +1,304 @@ +db = $db; + $this->config = $config; + $this->request = $request; + $this->user = $user; + $this->auth_provider_oauth_table = $auth_provider_oauth_table; + $this->services = array(); + } + + /** + * {@inheritdoc} + */ + public function login($username, $password) + { + // Requst the name of the OAuth service + $service_name = $this->request->variable('oauth_service', '', false, phpbb_request_interface::POST); + if ($service_name === '') + { + return array( + 'status' => LOGIN_ERROR_EXTERNAL_AUTH, + // TODO: change error message + 'error_msg' => 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE', + 'user_row' => array('user_id' => ANONYMOUS), + ); + } + + // Get the service credentials for the given service + $service_credentials = $this->get_credentials($service_name); + + // Check that the service has settings + if ($service_credentials['key'] == false || $service_credentials['secret'] == false) + { + return array( + 'status' => LOGIN_ERROR_EXTERNAL_AUTH, + // TODO: change error message + 'error_msg' => 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE', + 'user_row' => array('user_id' => ANONYMOUS), + ); + } + + $storage = new phpbb_auth_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_table); + $service = $this->get_service($service_name, $storage, $service_credentials, $this->get_scopes($service_name)); + + if ($this->request->is_set('code', phpbb_request_interface::GET)) + { + // This was a callback request from the service provider + $service->requestAccessToken( $_GET['code'] ); + + // Send a request with it + $path = $this->get_path($service_name); + if ($path) + { + $result = json_decode( $service->request($path), true ); + } + + // Perform authentication + } else { + $url = $service->getAuthorizationUri(); + // TODO: modify $url for the appropriate return points + header('Location: ' . $url); + } + } + + /** + * Returns an array containing the service credentials belonging to requested + * service. + * + * @param string $service_name The name of the service + * @return array An array containing the 'key' and the 'secret' of the + * service in the form: + * array( + * 'key' => string + * 'secret' => string + * ) + */ + protected function get_service_credentials($service_name) + { + return array( + 'key' => $this->config['auth_oauth_' . $service_name . '_key'], + 'secret' => $this->config['auth_oauth_' . $service_name . '_secret'], + ); + } + + /** + * Returns the cached current_uri object or creates and caches it if it is + * not already created + * + * @return \OAuth\Common\Http\Uri\UriInterface + */ + protected function get_current_uri() + { + if ($this->current_uri) + { + return $this->current_uri; + } + + $uri_factory = new \OAuth\Common\Http\Uri\UriFactory(); + $current_uri = $uri_factory->createFromSuperGlobalArray($this->request->get_super_global(phpbb_request_interface::SERVER)); + $current_uri->setQuery(''); + + $this->current_uri = $current_uri; + return $current_uri; + } + + /** + * Returns the cached service object or creates a new one + * + * @param string $service_name The name of the service + * @param phpbb_auth_oauth_token_storage $storage + * @param array $service_credentials {@see phpbb_auth_provider_oauth::get_service_credentials} + * @param array $scope The scope of the request against + * the api. + * @return \OAuth\Common\Service\ServiceInterface + */ + protected function get_service($service_name, phpbb_auth_oauth_token_storage $storage, array $service_credentials, array $scopes = array()) + { + if ($this->services[$service_name]) + { + return $this->services[$service_name]; + } + + $current_uri = $this->get_current_uri(); + + // Setup the credentials for the requests + $credentials = new Credentials( + $service_credentials['key'], + $service_credentials['secret'], + $current_uri->getAbsoluteUri() + ); + + $service_factory = new \OAuth\ServiceFactory(); + $this->service[$service_name] = $service_factory->createService($service_name, $credentials, $storage, $scopes); + + return $this->service[$service_name]; + } + + /** + * Returns the scopes of the service required for authentication + * + * @param string $service_name + * @return array An array of the scopes required from the service + */ + protected function get_scopes($service_name) + { + $scopes = array(); + + switch ($service_name) + { + case 'GitHub': + $scopes[] = 'user'; + break; + case 'google': + $scopes[] = 'userinfo_email'; + $scopes[] = 'userinfo_profile'; + break; + case 'instagram': + case 'microsoft': + $scopes[] = 'basic'; + break; + case 'linkedin': + $scopes[] = 'r_basicprofile'; + break; + } + + return $scopes; + } + + /** + * Returns the path desired of the service + * + * @param string $service_name + * @return string|UriInterface|null A null return means do not + * request additional information. + */ + protected function get_path($service_name) + { + switch ($service_name) + { + case 'bitly': + case 'tumblr': + $path = 'user/info'; + break; + case 'box': + $path = '/users/me'; + break; + case 'facebook': + $path = '/me'; + break; + case 'FitBit': + $path = 'user/-/profile.json'; + break; + case 'foursquare': + case 'instagram': + $path = 'users/self'; + break; + case 'GitHub': + $path = 'user/emails'; + break; + case 'google': + $path = 'https://www.googleapis.com/oauth2/v1/userinfo'; + break; + case 'linkedin': + $path = '/people/~?format=json'; + break; + case 'soundCloud': + $path = 'me.json'; + break; + case 'twitter': + $path = 'account/verify_credentials.json'; + break; + default: + $path = null; + break; + } + + return $path; + } +} -- cgit v1.2.1 From 117a758f6610ccc52142ca177504442cbd4869ab Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sun, 14 Jul 2013 14:07:59 -0400 Subject: [feature/oauth] Move oauth to auth/provider/oauth PHPBB3-11673 --- phpBB/phpbb/auth/oauth/token_storage.php | 220 ---------------- phpBB/phpbb/auth/provider/oauth.php | 304 ---------------------- phpBB/phpbb/auth/provider/oauth/oauth.php | 304 ++++++++++++++++++++++ phpBB/phpbb/auth/provider/oauth/token_storage.php | 220 ++++++++++++++++ 4 files changed, 524 insertions(+), 524 deletions(-) delete mode 100644 phpBB/phpbb/auth/oauth/token_storage.php delete mode 100644 phpBB/phpbb/auth/provider/oauth.php create mode 100644 phpBB/phpbb/auth/provider/oauth/oauth.php create mode 100644 phpBB/phpbb/auth/provider/oauth/token_storage.php (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/oauth/token_storage.php b/phpBB/phpbb/auth/oauth/token_storage.php deleted file mode 100644 index fcc277053c..0000000000 --- a/phpBB/phpbb/auth/oauth/token_storage.php +++ /dev/null @@ -1,220 +0,0 @@ -db = $db; - $this->user = $user; - $this->service_name = $service_name; - $this->auth_provider_oauth_table = $auth_provider_oauth_table; - } - - /** - * {@inheritdoc} - */ - public function retrieveAccessToken() - { - if( $this->cachedToken instanceOf TokenInterface ) { - return $this->token; - } - - $data = array( - 'user_id' => $this->user->data['user_id'], - 'oauth_provider' => $this->service_name, - ); - - if ($this->user->data['user_id'] == ANONYMOUS) - { - $data['session_id'] = $this->user->data['session_id']; - } - - $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . ' - WHERE ' . $this->db->sql_build_array('SELECT', $data); - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if (!$row) - { - // TODO: translate - throw new TokenNotFoundException('Token not stored'); - } - - $token = unserialize($row['oauth_token']); - - // Ensure that the token was serialized/unserialized correctly - if (!($token instanceof TokenInterface)) - { - $this->clearToken(); - // TODO: translate - throw new TokenNotFoundException('Token not stored correctly'); - } - - $this->cachedToken = $token; - return $token; - } - - /** - * {@inheritdoc} - */ - public function storeAccessToken(TokenInterface $token) - { - $this->cachedToken = $token; - - $data = array( - 'user_id' => $this->user->data['user_id'], - 'oauth_provider' => $this->service_name, - 'oauth_token' => serialize($token), - ); - - if ($this->user->data['user_id'] == ANONYMOUS) - { - $data['session_id'] = $this->user->data['session_id']; - } - - $sql = 'INSERT INTO ' . $this->auth_provider_oauth_table . ' - WHERE ' . $this->db->sql_build_array('INSERT', $data); - $this->db->sql_query($sql); - } - - /** - * {@inheritdoc} - */ - public function hasAccessToken() - { - if( $this->cachedToken ) { - return true; - } - - $data = array( - 'user_id' => $this->user->data['user_id'], - 'oauth_provider' => $this->service_name, - ); - - if ($this->user->data['user_id'] == ANONYMOUS) - { - $data['session_id'] = $this->user->data['session_id']; - } - - $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . ' - WHERE ' . $this->db->sql_build_array('SELECT', $data); - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if (!$row) - { - return false; - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function clearToken() - { - $this->cachedToken = null; - - $sql = 'DELETE FROM ' . $this->auth_provider_oauth_table . ' - WHERE user_id = ' . $this->user->data['user_id'] . ' - AND oauth_provider = ' . $this->db->sql_escape($this->oauth_provider); - - if ($this->user->data['user_id'] == ANONYMOUS) - { - $sql .= ' AND session_id = ' . $this->user->data['session_id']; - } - - $this->db->sql_query($sql); - } - - /** - * Updates the user_id field in the database assosciated with the token - * - * @param int $user_id - */ - public function set_user_id($user_id) - { - if (!$this->cachedToken) - { - return; - } - - $sql = 'UPDATE ' . $this->auth_provider_oauth_table . ' - SET ' . $db->sql_build_array('UPDATE', array( - 'user_id' => (int) $user_id - )) . ' - WHERE user_id = ' . $this->user->data['user_id'] . ' - AND session_id = ' . $this->user->data['session_id']; - $this->db->sql_query($sql); - } -} diff --git a/phpBB/phpbb/auth/provider/oauth.php b/phpBB/phpbb/auth/provider/oauth.php deleted file mode 100644 index aeca2a4869..0000000000 --- a/phpBB/phpbb/auth/provider/oauth.php +++ /dev/null @@ -1,304 +0,0 @@ -db = $db; - $this->config = $config; - $this->request = $request; - $this->user = $user; - $this->auth_provider_oauth_table = $auth_provider_oauth_table; - $this->services = array(); - } - - /** - * {@inheritdoc} - */ - public function login($username, $password) - { - // Requst the name of the OAuth service - $service_name = $this->request->variable('oauth_service', '', false, phpbb_request_interface::POST); - if ($service_name === '') - { - return array( - 'status' => LOGIN_ERROR_EXTERNAL_AUTH, - // TODO: change error message - 'error_msg' => 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - // Get the service credentials for the given service - $service_credentials = $this->get_credentials($service_name); - - // Check that the service has settings - if ($service_credentials['key'] == false || $service_credentials['secret'] == false) - { - return array( - 'status' => LOGIN_ERROR_EXTERNAL_AUTH, - // TODO: change error message - 'error_msg' => 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } - - $storage = new phpbb_auth_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_table); - $service = $this->get_service($service_name, $storage, $service_credentials, $this->get_scopes($service_name)); - - if ($this->request->is_set('code', phpbb_request_interface::GET)) - { - // This was a callback request from the service provider - $service->requestAccessToken( $_GET['code'] ); - - // Send a request with it - $path = $this->get_path($service_name); - if ($path) - { - $result = json_decode( $service->request($path), true ); - } - - // Perform authentication - } else { - $url = $service->getAuthorizationUri(); - // TODO: modify $url for the appropriate return points - header('Location: ' . $url); - } - } - - /** - * Returns an array containing the service credentials belonging to requested - * service. - * - * @param string $service_name The name of the service - * @return array An array containing the 'key' and the 'secret' of the - * service in the form: - * array( - * 'key' => string - * 'secret' => string - * ) - */ - protected function get_service_credentials($service_name) - { - return array( - 'key' => $this->config['auth_oauth_' . $service_name . '_key'], - 'secret' => $this->config['auth_oauth_' . $service_name . '_secret'], - ); - } - - /** - * Returns the cached current_uri object or creates and caches it if it is - * not already created - * - * @return \OAuth\Common\Http\Uri\UriInterface - */ - protected function get_current_uri() - { - if ($this->current_uri) - { - return $this->current_uri; - } - - $uri_factory = new \OAuth\Common\Http\Uri\UriFactory(); - $current_uri = $uri_factory->createFromSuperGlobalArray($this->request->get_super_global(phpbb_request_interface::SERVER)); - $current_uri->setQuery(''); - - $this->current_uri = $current_uri; - return $current_uri; - } - - /** - * Returns the cached service object or creates a new one - * - * @param string $service_name The name of the service - * @param phpbb_auth_oauth_token_storage $storage - * @param array $service_credentials {@see phpbb_auth_provider_oauth::get_service_credentials} - * @param array $scope The scope of the request against - * the api. - * @return \OAuth\Common\Service\ServiceInterface - */ - protected function get_service($service_name, phpbb_auth_oauth_token_storage $storage, array $service_credentials, array $scopes = array()) - { - if ($this->services[$service_name]) - { - return $this->services[$service_name]; - } - - $current_uri = $this->get_current_uri(); - - // Setup the credentials for the requests - $credentials = new Credentials( - $service_credentials['key'], - $service_credentials['secret'], - $current_uri->getAbsoluteUri() - ); - - $service_factory = new \OAuth\ServiceFactory(); - $this->service[$service_name] = $service_factory->createService($service_name, $credentials, $storage, $scopes); - - return $this->service[$service_name]; - } - - /** - * Returns the scopes of the service required for authentication - * - * @param string $service_name - * @return array An array of the scopes required from the service - */ - protected function get_scopes($service_name) - { - $scopes = array(); - - switch ($service_name) - { - case 'GitHub': - $scopes[] = 'user'; - break; - case 'google': - $scopes[] = 'userinfo_email'; - $scopes[] = 'userinfo_profile'; - break; - case 'instagram': - case 'microsoft': - $scopes[] = 'basic'; - break; - case 'linkedin': - $scopes[] = 'r_basicprofile'; - break; - } - - return $scopes; - } - - /** - * Returns the path desired of the service - * - * @param string $service_name - * @return string|UriInterface|null A null return means do not - * request additional information. - */ - protected function get_path($service_name) - { - switch ($service_name) - { - case 'bitly': - case 'tumblr': - $path = 'user/info'; - break; - case 'box': - $path = '/users/me'; - break; - case 'facebook': - $path = '/me'; - break; - case 'FitBit': - $path = 'user/-/profile.json'; - break; - case 'foursquare': - case 'instagram': - $path = 'users/self'; - break; - case 'GitHub': - $path = 'user/emails'; - break; - case 'google': - $path = 'https://www.googleapis.com/oauth2/v1/userinfo'; - break; - case 'linkedin': - $path = '/people/~?format=json'; - break; - case 'soundCloud': - $path = 'me.json'; - break; - case 'twitter': - $path = 'account/verify_credentials.json'; - break; - default: - $path = null; - break; - } - - return $path; - } -} diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php new file mode 100644 index 0000000000..aeca2a4869 --- /dev/null +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -0,0 +1,304 @@ +db = $db; + $this->config = $config; + $this->request = $request; + $this->user = $user; + $this->auth_provider_oauth_table = $auth_provider_oauth_table; + $this->services = array(); + } + + /** + * {@inheritdoc} + */ + public function login($username, $password) + { + // Requst the name of the OAuth service + $service_name = $this->request->variable('oauth_service', '', false, phpbb_request_interface::POST); + if ($service_name === '') + { + return array( + 'status' => LOGIN_ERROR_EXTERNAL_AUTH, + // TODO: change error message + 'error_msg' => 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE', + 'user_row' => array('user_id' => ANONYMOUS), + ); + } + + // Get the service credentials for the given service + $service_credentials = $this->get_credentials($service_name); + + // Check that the service has settings + if ($service_credentials['key'] == false || $service_credentials['secret'] == false) + { + return array( + 'status' => LOGIN_ERROR_EXTERNAL_AUTH, + // TODO: change error message + 'error_msg' => 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE', + 'user_row' => array('user_id' => ANONYMOUS), + ); + } + + $storage = new phpbb_auth_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_table); + $service = $this->get_service($service_name, $storage, $service_credentials, $this->get_scopes($service_name)); + + if ($this->request->is_set('code', phpbb_request_interface::GET)) + { + // This was a callback request from the service provider + $service->requestAccessToken( $_GET['code'] ); + + // Send a request with it + $path = $this->get_path($service_name); + if ($path) + { + $result = json_decode( $service->request($path), true ); + } + + // Perform authentication + } else { + $url = $service->getAuthorizationUri(); + // TODO: modify $url for the appropriate return points + header('Location: ' . $url); + } + } + + /** + * Returns an array containing the service credentials belonging to requested + * service. + * + * @param string $service_name The name of the service + * @return array An array containing the 'key' and the 'secret' of the + * service in the form: + * array( + * 'key' => string + * 'secret' => string + * ) + */ + protected function get_service_credentials($service_name) + { + return array( + 'key' => $this->config['auth_oauth_' . $service_name . '_key'], + 'secret' => $this->config['auth_oauth_' . $service_name . '_secret'], + ); + } + + /** + * Returns the cached current_uri object or creates and caches it if it is + * not already created + * + * @return \OAuth\Common\Http\Uri\UriInterface + */ + protected function get_current_uri() + { + if ($this->current_uri) + { + return $this->current_uri; + } + + $uri_factory = new \OAuth\Common\Http\Uri\UriFactory(); + $current_uri = $uri_factory->createFromSuperGlobalArray($this->request->get_super_global(phpbb_request_interface::SERVER)); + $current_uri->setQuery(''); + + $this->current_uri = $current_uri; + return $current_uri; + } + + /** + * Returns the cached service object or creates a new one + * + * @param string $service_name The name of the service + * @param phpbb_auth_oauth_token_storage $storage + * @param array $service_credentials {@see phpbb_auth_provider_oauth::get_service_credentials} + * @param array $scope The scope of the request against + * the api. + * @return \OAuth\Common\Service\ServiceInterface + */ + protected function get_service($service_name, phpbb_auth_oauth_token_storage $storage, array $service_credentials, array $scopes = array()) + { + if ($this->services[$service_name]) + { + return $this->services[$service_name]; + } + + $current_uri = $this->get_current_uri(); + + // Setup the credentials for the requests + $credentials = new Credentials( + $service_credentials['key'], + $service_credentials['secret'], + $current_uri->getAbsoluteUri() + ); + + $service_factory = new \OAuth\ServiceFactory(); + $this->service[$service_name] = $service_factory->createService($service_name, $credentials, $storage, $scopes); + + return $this->service[$service_name]; + } + + /** + * Returns the scopes of the service required for authentication + * + * @param string $service_name + * @return array An array of the scopes required from the service + */ + protected function get_scopes($service_name) + { + $scopes = array(); + + switch ($service_name) + { + case 'GitHub': + $scopes[] = 'user'; + break; + case 'google': + $scopes[] = 'userinfo_email'; + $scopes[] = 'userinfo_profile'; + break; + case 'instagram': + case 'microsoft': + $scopes[] = 'basic'; + break; + case 'linkedin': + $scopes[] = 'r_basicprofile'; + break; + } + + return $scopes; + } + + /** + * Returns the path desired of the service + * + * @param string $service_name + * @return string|UriInterface|null A null return means do not + * request additional information. + */ + protected function get_path($service_name) + { + switch ($service_name) + { + case 'bitly': + case 'tumblr': + $path = 'user/info'; + break; + case 'box': + $path = '/users/me'; + break; + case 'facebook': + $path = '/me'; + break; + case 'FitBit': + $path = 'user/-/profile.json'; + break; + case 'foursquare': + case 'instagram': + $path = 'users/self'; + break; + case 'GitHub': + $path = 'user/emails'; + break; + case 'google': + $path = 'https://www.googleapis.com/oauth2/v1/userinfo'; + break; + case 'linkedin': + $path = '/people/~?format=json'; + break; + case 'soundCloud': + $path = 'me.json'; + break; + case 'twitter': + $path = 'account/verify_credentials.json'; + break; + default: + $path = null; + break; + } + + return $path; + } +} diff --git a/phpBB/phpbb/auth/provider/oauth/token_storage.php b/phpBB/phpbb/auth/provider/oauth/token_storage.php new file mode 100644 index 0000000000..fcc277053c --- /dev/null +++ b/phpBB/phpbb/auth/provider/oauth/token_storage.php @@ -0,0 +1,220 @@ +db = $db; + $this->user = $user; + $this->service_name = $service_name; + $this->auth_provider_oauth_table = $auth_provider_oauth_table; + } + + /** + * {@inheritdoc} + */ + public function retrieveAccessToken() + { + if( $this->cachedToken instanceOf TokenInterface ) { + return $this->token; + } + + $data = array( + 'user_id' => $this->user->data['user_id'], + 'oauth_provider' => $this->service_name, + ); + + if ($this->user->data['user_id'] == ANONYMOUS) + { + $data['session_id'] = $this->user->data['session_id']; + } + + $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . ' + WHERE ' . $this->db->sql_build_array('SELECT', $data); + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if (!$row) + { + // TODO: translate + throw new TokenNotFoundException('Token not stored'); + } + + $token = unserialize($row['oauth_token']); + + // Ensure that the token was serialized/unserialized correctly + if (!($token instanceof TokenInterface)) + { + $this->clearToken(); + // TODO: translate + throw new TokenNotFoundException('Token not stored correctly'); + } + + $this->cachedToken = $token; + return $token; + } + + /** + * {@inheritdoc} + */ + public function storeAccessToken(TokenInterface $token) + { + $this->cachedToken = $token; + + $data = array( + 'user_id' => $this->user->data['user_id'], + 'oauth_provider' => $this->service_name, + 'oauth_token' => serialize($token), + ); + + if ($this->user->data['user_id'] == ANONYMOUS) + { + $data['session_id'] = $this->user->data['session_id']; + } + + $sql = 'INSERT INTO ' . $this->auth_provider_oauth_table . ' + WHERE ' . $this->db->sql_build_array('INSERT', $data); + $this->db->sql_query($sql); + } + + /** + * {@inheritdoc} + */ + public function hasAccessToken() + { + if( $this->cachedToken ) { + return true; + } + + $data = array( + 'user_id' => $this->user->data['user_id'], + 'oauth_provider' => $this->service_name, + ); + + if ($this->user->data['user_id'] == ANONYMOUS) + { + $data['session_id'] = $this->user->data['session_id']; + } + + $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . ' + WHERE ' . $this->db->sql_build_array('SELECT', $data); + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if (!$row) + { + return false; + } + + return true; + } + + /** + * {@inheritdoc} + */ + public function clearToken() + { + $this->cachedToken = null; + + $sql = 'DELETE FROM ' . $this->auth_provider_oauth_table . ' + WHERE user_id = ' . $this->user->data['user_id'] . ' + AND oauth_provider = ' . $this->db->sql_escape($this->oauth_provider); + + if ($this->user->data['user_id'] == ANONYMOUS) + { + $sql .= ' AND session_id = ' . $this->user->data['session_id']; + } + + $this->db->sql_query($sql); + } + + /** + * Updates the user_id field in the database assosciated with the token + * + * @param int $user_id + */ + public function set_user_id($user_id) + { + if (!$this->cachedToken) + { + return; + } + + $sql = 'UPDATE ' . $this->auth_provider_oauth_table . ' + SET ' . $db->sql_build_array('UPDATE', array( + 'user_id' => (int) $user_id + )) . ' + WHERE user_id = ' . $this->user->data['user_id'] . ' + AND session_id = ' . $this->user->data['session_id']; + $this->db->sql_query($sql); + } +} -- cgit v1.2.1 From a43a8f8c72f14b683f7db39a20c6d5fc4f154744 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sun, 14 Jul 2013 14:09:13 -0400 Subject: [feature/oauth] Update class name based on last commit PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 2 +- phpBB/phpbb/auth/provider/oauth/token_storage.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index aeca2a4869..b6af9758e7 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -124,7 +124,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base ); } - $storage = new phpbb_auth_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_table); + $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_table); $service = $this->get_service($service_name, $storage, $service_credentials, $this->get_scopes($service_name)); if ($this->request->is_set('code', phpbb_request_interface::GET)) diff --git a/phpBB/phpbb/auth/provider/oauth/token_storage.php b/phpBB/phpbb/auth/provider/oauth/token_storage.php index fcc277053c..227b51efc9 100644 --- a/phpBB/phpbb/auth/provider/oauth/token_storage.php +++ b/phpBB/phpbb/auth/provider/oauth/token_storage.php @@ -26,7 +26,7 @@ use OAuth\Common\Storage\Exception\TokenNotFoundException; * * @package auth */ -class phpbb_auth_oauth_token_storage implements TokenStorageInterface +class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface { /** * Cache driver. -- cgit v1.2.1 From 00d0e102008767f712145f55348a662f3e6750d6 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sun, 14 Jul 2013 14:17:54 -0400 Subject: [feature/oauth] Move last file to appropriate location PHPBB3-11673 --- .../db/migration/data/310/auth_provider_oauth.php | 45 ---------------------- .../db/migration/data/310/auth_provider_oauth.php | 45 ++++++++++++++++++++++ 2 files changed, 45 insertions(+), 45 deletions(-) delete mode 100644 phpBB/includes/db/migration/data/310/auth_provider_oauth.php create mode 100644 phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php (limited to 'phpBB') diff --git a/phpBB/includes/db/migration/data/310/auth_provider_oauth.php b/phpBB/includes/db/migration/data/310/auth_provider_oauth.php deleted file mode 100644 index 92da42ba31..0000000000 --- a/phpBB/includes/db/migration/data/310/auth_provider_oauth.php +++ /dev/null @@ -1,45 +0,0 @@ -db_tools->sql_table_exists($this->table_prefix . 'auth_provider_oauth'); - } - - public function update_schema() - { - return array( - 'add_tables' => array( - $this->table_prefix . 'auth_provider_oauth' => array( - 'COLUMNS' => array( - 'user_id' => array('UINT', 0), // phpbb_users.user_id - 'session_id' => array('CHAR:32', ''), // phpbb_sessions.session_id used only when user_id not set - 'oauth_provider' => array('VCHAR'), // Name of the OAuth provider - 'oauth_token' => array('TEXT_UNI'), // Serialized token - ), - 'KEYS' => array( - 'user_id' => array('INDEX', 'user_id'), - 'oauth_provider' => array('INDEX', 'oauth_provider'), - ), - ), - ), - ); - } - - public function revert_schema() - { - return array( - 'drop_tables' => array( - $this->table_prefix . 'auth_provider_oauth', - ), - ); - } -} diff --git a/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php b/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php new file mode 100644 index 0000000000..92da42ba31 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php @@ -0,0 +1,45 @@ +db_tools->sql_table_exists($this->table_prefix . 'auth_provider_oauth'); + } + + public function update_schema() + { + return array( + 'add_tables' => array( + $this->table_prefix . 'auth_provider_oauth' => array( + 'COLUMNS' => array( + 'user_id' => array('UINT', 0), // phpbb_users.user_id + 'session_id' => array('CHAR:32', ''), // phpbb_sessions.session_id used only when user_id not set + 'oauth_provider' => array('VCHAR'), // Name of the OAuth provider + 'oauth_token' => array('TEXT_UNI'), // Serialized token + ), + 'KEYS' => array( + 'user_id' => array('INDEX', 'user_id'), + 'oauth_provider' => array('INDEX', 'oauth_provider'), + ), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_tables' => array( + $this->table_prefix . 'auth_provider_oauth', + ), + ); + } +} -- cgit v1.2.1 From 4311cd65e30b994c5ecd07baf0a508f40d51f155 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 14 Jul 2013 14:29:11 -0400 Subject: [ticket/11700] Instantiate the class loader with namespace rather than prefix PHPBB3-11700 --- phpBB/common.php | 2 +- phpBB/install/database_update.php | 2 +- phpBB/install/index.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/common.php b/phpBB/common.php index 962a1f951f..41d367d43c 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -85,7 +85,7 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); // Setup class loader first -$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}phpbb/", $phpEx); +$phpbb_class_loader = new phpbb_class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx); $phpbb_class_loader->register(); $phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", $phpEx); $phpbb_class_loader_ext->register(); diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index cd6fb7931b..19db0a9fc1 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -95,7 +95,7 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); // Setup class loader first -$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}phpbb/", $phpEx); +$phpbb_class_loader = new phpbb_class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx); $phpbb_class_loader->register(); // Set up container (must be done here because extensions table may not exist) diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 45e5777e36..65f33766b5 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -90,7 +90,7 @@ include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); require($phpbb_root_path . 'includes/functions_install.' . $phpEx); // Setup class loader first -$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}phpbb/", $phpEx); +$phpbb_class_loader = new phpbb_class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx); $phpbb_class_loader->register(); $phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", $phpEx); $phpbb_class_loader_ext->register(); -- cgit v1.2.1 From 947aa2b6b442b5e1ce06c755c3e8ebea677f63e3 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sun, 14 Jul 2013 15:16:34 -0400 Subject: [feature/oauth] Create OAuth service classes PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 31 ------------------- phpBB/phpbb/auth/provider/oauth/service/base.php | 32 ++++++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/bitly.php | 26 ++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/box.php | 26 ++++++++++++++++ .../phpbb/auth/provider/oauth/service/facebook.php | 26 ++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/fitbit.php | 26 ++++++++++++++++ .../auth/provider/oauth/service/foursqare.php | 26 ++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/github.php | 34 +++++++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/google.php | 35 ++++++++++++++++++++++ .../auth/provider/oauth/service/instagram.php | 34 +++++++++++++++++++++ .../auth/provider/oauth/service/interface.php | 31 +++++++++++++++++++ .../phpbb/auth/provider/oauth/service/linkedin.php | 34 +++++++++++++++++++++ .../auth/provider/oauth/service/microsoft.php | 34 +++++++++++++++++++++ .../auth/provider/oauth/service/soundcloud.php | 26 ++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/tumblr.php | 26 ++++++++++++++++ .../phpbb/auth/provider/oauth/service/twitter.php | 26 ++++++++++++++++ 16 files changed, 442 insertions(+), 31 deletions(-) create mode 100644 phpBB/phpbb/auth/provider/oauth/service/base.php create mode 100644 phpBB/phpbb/auth/provider/oauth/service/bitly.php create mode 100644 phpBB/phpbb/auth/provider/oauth/service/box.php create mode 100644 phpBB/phpbb/auth/provider/oauth/service/facebook.php create mode 100644 phpBB/phpbb/auth/provider/oauth/service/fitbit.php create mode 100644 phpBB/phpbb/auth/provider/oauth/service/foursqare.php create mode 100644 phpBB/phpbb/auth/provider/oauth/service/github.php create mode 100644 phpBB/phpbb/auth/provider/oauth/service/google.php create mode 100644 phpBB/phpbb/auth/provider/oauth/service/instagram.php create mode 100644 phpBB/phpbb/auth/provider/oauth/service/interface.php create mode 100644 phpBB/phpbb/auth/provider/oauth/service/linkedin.php create mode 100644 phpBB/phpbb/auth/provider/oauth/service/microsoft.php create mode 100644 phpBB/phpbb/auth/provider/oauth/service/soundcloud.php create mode 100644 phpBB/phpbb/auth/provider/oauth/service/tumblr.php create mode 100644 phpBB/phpbb/auth/provider/oauth/service/twitter.php (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index b6af9758e7..75e8a54ed4 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -220,37 +220,6 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base return $this->service[$service_name]; } - /** - * Returns the scopes of the service required for authentication - * - * @param string $service_name - * @return array An array of the scopes required from the service - */ - protected function get_scopes($service_name) - { - $scopes = array(); - - switch ($service_name) - { - case 'GitHub': - $scopes[] = 'user'; - break; - case 'google': - $scopes[] = 'userinfo_email'; - $scopes[] = 'userinfo_profile'; - break; - case 'instagram': - case 'microsoft': - $scopes[] = 'basic'; - break; - case 'linkedin': - $scopes[] = 'r_basicprofile'; - break; - } - - return $scopes; - } - /** * Returns the path desired of the service * diff --git a/phpBB/phpbb/auth/provider/oauth/service/base.php b/phpBB/phpbb/auth/provider/oauth/service/base.php new file mode 100644 index 0000000000..98a1fa16e4 --- /dev/null +++ b/phpBB/phpbb/auth/provider/oauth/service/base.php @@ -0,0 +1,32 @@ + Date: Sun, 14 Jul 2013 15:35:12 -0400 Subject: [feature/oauth] Last five oauth services PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/service/amazon.php | 26 ++++++++++++++++++++++ .../phpbb/auth/provider/oauth/service/dropbox.php | 26 ++++++++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/paypal.php | 26 ++++++++++++++++++++++ .../auth/provider/oauth/service/vkontakte.php | 26 ++++++++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/yammer.php | 26 ++++++++++++++++++++++ 5 files changed, 130 insertions(+) create mode 100644 phpBB/phpbb/auth/provider/oauth/service/amazon.php create mode 100644 phpBB/phpbb/auth/provider/oauth/service/dropbox.php create mode 100644 phpBB/phpbb/auth/provider/oauth/service/paypal.php create mode 100644 phpBB/phpbb/auth/provider/oauth/service/vkontakte.php create mode 100644 phpBB/phpbb/auth/provider/oauth/service/yammer.php (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/service/amazon.php b/phpBB/phpbb/auth/provider/oauth/service/amazon.php new file mode 100644 index 0000000000..1348bd5ebe --- /dev/null +++ b/phpBB/phpbb/auth/provider/oauth/service/amazon.php @@ -0,0 +1,26 @@ + Date: Sun, 14 Jul 2013 15:38:04 -0400 Subject: [ticket/11700] include and define are not valid class names PHPBB3-11700 --- phpBB/phpbb/template/twig/extension.php | 4 +- phpBB/phpbb/template/twig/node/define.php | 58 ------------------- phpBB/phpbb/template/twig/node/definenode.php | 58 +++++++++++++++++++ phpBB/phpbb/template/twig/node/include.php | 56 ------------------ phpBB/phpbb/template/twig/node/includenode.php | 56 ++++++++++++++++++ phpBB/phpbb/template/twig/tokenparser/define.php | 66 ---------------------- .../template/twig/tokenparser/defineparser.php | 66 ++++++++++++++++++++++ phpBB/phpbb/template/twig/tokenparser/include.php | 46 --------------- .../template/twig/tokenparser/includeparser.php | 46 +++++++++++++++ 9 files changed, 228 insertions(+), 228 deletions(-) delete mode 100644 phpBB/phpbb/template/twig/node/define.php create mode 100644 phpBB/phpbb/template/twig/node/definenode.php delete mode 100644 phpBB/phpbb/template/twig/node/include.php create mode 100644 phpBB/phpbb/template/twig/node/includenode.php delete mode 100644 phpBB/phpbb/template/twig/tokenparser/define.php create mode 100644 phpBB/phpbb/template/twig/tokenparser/defineparser.php delete mode 100644 phpBB/phpbb/template/twig/tokenparser/include.php create mode 100644 phpBB/phpbb/template/twig/tokenparser/includeparser.php (limited to 'phpBB') diff --git a/phpBB/phpbb/template/twig/extension.php b/phpBB/phpbb/template/twig/extension.php index c279726434..2adee07c8c 100644 --- a/phpBB/phpbb/template/twig/extension.php +++ b/phpBB/phpbb/template/twig/extension.php @@ -54,8 +54,8 @@ class phpbb_template_twig_extension extends Twig_Extension public function getTokenParsers() { return array( - new phpbb_template_twig_tokenparser_define, - new phpbb_template_twig_tokenparser_include, + new phpbb_template_twig_tokenparser_defineparser, + new phpbb_template_twig_tokenparser_includeparser, new phpbb_template_twig_tokenparser_includejs, new phpbb_template_twig_tokenparser_includecss, new phpbb_template_twig_tokenparser_event, diff --git a/phpBB/phpbb/template/twig/node/define.php b/phpBB/phpbb/template/twig/node/define.php deleted file mode 100644 index fcb19cc773..0000000000 --- a/phpBB/phpbb/template/twig/node/define.php +++ /dev/null @@ -1,58 +0,0 @@ - $name, 'value' => $value), array('capture' => $capture, 'safe' => false), $lineno, $tag); - } - - /** - * Compiles the node to PHP. - * - * @param Twig_Compiler A Twig_Compiler instance - */ - public function compile(Twig_Compiler $compiler) - { - $compiler->addDebugInfo($this); - - if ($this->getAttribute('capture')) { - $compiler - ->write("ob_start();\n") - ->subcompile($this->getNode('value')) - ; - - $compiler->write("\$value = ('' === \$value = ob_get_clean()) ? '' : new Twig_Markup(\$value, \$this->env->getCharset());\n"); - } - else - { - $compiler - ->write("\$value = ") - ->subcompile($this->getNode('value')) - ->raw(";\n") - ; - } - - $compiler - ->write("\$context['definition']->set('") - ->raw($this->getNode('name')->getAttribute('name')) - ->raw("', \$value);\n") - ; - } -} diff --git a/phpBB/phpbb/template/twig/node/definenode.php b/phpBB/phpbb/template/twig/node/definenode.php new file mode 100644 index 0000000000..247b908337 --- /dev/null +++ b/phpBB/phpbb/template/twig/node/definenode.php @@ -0,0 +1,58 @@ + $name, 'value' => $value), array('capture' => $capture, 'safe' => false), $lineno, $tag); + } + + /** + * Compiles the node to PHP. + * + * @param Twig_Compiler A Twig_Compiler instance + */ + public function compile(Twig_Compiler $compiler) + { + $compiler->addDebugInfo($this); + + if ($this->getAttribute('capture')) { + $compiler + ->write("ob_start();\n") + ->subcompile($this->getNode('value')) + ; + + $compiler->write("\$value = ('' === \$value = ob_get_clean()) ? '' : new Twig_Markup(\$value, \$this->env->getCharset());\n"); + } + else + { + $compiler + ->write("\$value = ") + ->subcompile($this->getNode('value')) + ->raw(";\n") + ; + } + + $compiler + ->write("\$context['definition']->set('") + ->raw($this->getNode('name')->getAttribute('name')) + ->raw("', \$value);\n") + ; + } +} diff --git a/phpBB/phpbb/template/twig/node/include.php b/phpBB/phpbb/template/twig/node/include.php deleted file mode 100644 index 5c6ae1bbcf..0000000000 --- a/phpBB/phpbb/template/twig/node/include.php +++ /dev/null @@ -1,56 +0,0 @@ -addDebugInfo($this); - - $compiler - ->write("\$location = ") - ->subcompile($this->getNode('expr')) - ->raw(";\n") - ->write("\$namespace = false;\n") - ->write("if (strpos(\$location, '@') === 0) {\n") - ->indent() - ->write("\$namespace = substr(\$location, 1, strpos(\$location, '/') - 1);\n") - ->write("\$previous_look_up_order = \$this->env->getNamespaceLookUpOrder();\n") - - // We set the namespace lookup order to be this namespace first, then the main path - ->write("\$this->env->setNamespaceLookUpOrder(array(\$namespace, '__main__'));\n") - ->outdent() - ->write("}\n") - ; - - parent::compile($compiler); - - $compiler - ->write("if (\$namespace) {\n") - ->indent() - ->write("\$this->env->setNamespaceLookUpOrder(\$previous_look_up_order);\n") - ->outdent() - ->write("}\n") - ; - } -} diff --git a/phpBB/phpbb/template/twig/node/includenode.php b/phpBB/phpbb/template/twig/node/includenode.php new file mode 100644 index 0000000000..c5d1c6be51 --- /dev/null +++ b/phpBB/phpbb/template/twig/node/includenode.php @@ -0,0 +1,56 @@ +addDebugInfo($this); + + $compiler + ->write("\$location = ") + ->subcompile($this->getNode('expr')) + ->raw(";\n") + ->write("\$namespace = false;\n") + ->write("if (strpos(\$location, '@') === 0) {\n") + ->indent() + ->write("\$namespace = substr(\$location, 1, strpos(\$location, '/') - 1);\n") + ->write("\$previous_look_up_order = \$this->env->getNamespaceLookUpOrder();\n") + + // We set the namespace lookup order to be this namespace first, then the main path + ->write("\$this->env->setNamespaceLookUpOrder(array(\$namespace, '__main__'));\n") + ->outdent() + ->write("}\n") + ; + + parent::compile($compiler); + + $compiler + ->write("if (\$namespace) {\n") + ->indent() + ->write("\$this->env->setNamespaceLookUpOrder(\$previous_look_up_order);\n") + ->outdent() + ->write("}\n") + ; + } +} diff --git a/phpBB/phpbb/template/twig/tokenparser/define.php b/phpBB/phpbb/template/twig/tokenparser/define.php deleted file mode 100644 index 4ea15388c4..0000000000 --- a/phpBB/phpbb/template/twig/tokenparser/define.php +++ /dev/null @@ -1,66 +0,0 @@ -getLine(); - $stream = $this->parser->getStream(); - $name = $this->parser->getExpressionParser()->parseExpression(); - - $capture = false; - if ($stream->test(Twig_Token::OPERATOR_TYPE, '=')) { - $stream->next(); - $value = $this->parser->getExpressionParser()->parseExpression(); - - $stream->expect(Twig_Token::BLOCK_END_TYPE); - } else { - $capture = true; - - $stream->expect(Twig_Token::BLOCK_END_TYPE); - - $value = $this->parser->subparse(array($this, 'decideBlockEnd'), true); - $stream->expect(Twig_Token::BLOCK_END_TYPE); - } - - return new phpbb_template_twig_node_define($capture, $name, $value, $lineno, $this->getTag()); - } - - public function decideBlockEnd(Twig_Token $token) - { - return $token->test('ENDDEFINE'); - } - - /** - * Gets the tag name associated with this token parser. - * - * @return string The tag name - */ - public function getTag() - { - return 'DEFINE'; - } -} diff --git a/phpBB/phpbb/template/twig/tokenparser/defineparser.php b/phpBB/phpbb/template/twig/tokenparser/defineparser.php new file mode 100644 index 0000000000..db023c67bf --- /dev/null +++ b/phpBB/phpbb/template/twig/tokenparser/defineparser.php @@ -0,0 +1,66 @@ +getLine(); + $stream = $this->parser->getStream(); + $name = $this->parser->getExpressionParser()->parseExpression(); + + $capture = false; + if ($stream->test(Twig_Token::OPERATOR_TYPE, '=')) { + $stream->next(); + $value = $this->parser->getExpressionParser()->parseExpression(); + + $stream->expect(Twig_Token::BLOCK_END_TYPE); + } else { + $capture = true; + + $stream->expect(Twig_Token::BLOCK_END_TYPE); + + $value = $this->parser->subparse(array($this, 'decideBlockEnd'), true); + $stream->expect(Twig_Token::BLOCK_END_TYPE); + } + + return new phpbb_template_twig_node_definenode($capture, $name, $value, $lineno, $this->getTag()); + } + + public function decideBlockEnd(Twig_Token $token) + { + return $token->test('ENDDEFINE'); + } + + /** + * Gets the tag name associated with this token parser. + * + * @return string The tag name + */ + public function getTag() + { + return 'DEFINE'; + } +} diff --git a/phpBB/phpbb/template/twig/tokenparser/include.php b/phpBB/phpbb/template/twig/tokenparser/include.php deleted file mode 100644 index 520f9fd1a0..0000000000 --- a/phpBB/phpbb/template/twig/tokenparser/include.php +++ /dev/null @@ -1,46 +0,0 @@ -parser->getExpressionParser()->parseExpression(); - - list($variables, $only, $ignoreMissing) = $this->parseArguments(); - - return new phpbb_template_twig_node_include($expr, $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag()); - } - - /** - * Gets the tag name associated with this token parser. - * - * @return string The tag name - */ - public function getTag() - { - return 'INCLUDE'; - } -} diff --git a/phpBB/phpbb/template/twig/tokenparser/includeparser.php b/phpBB/phpbb/template/twig/tokenparser/includeparser.php new file mode 100644 index 0000000000..79c53630d0 --- /dev/null +++ b/phpBB/phpbb/template/twig/tokenparser/includeparser.php @@ -0,0 +1,46 @@ +parser->getExpressionParser()->parseExpression(); + + list($variables, $only, $ignoreMissing) = $this->parseArguments(); + + return new phpbb_template_twig_node_includenode($expr, $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag()); + } + + /** + * Gets the tag name associated with this token parser. + * + * @return string The tag name + */ + public function getTag() + { + return 'INCLUDE'; + } +} -- cgit v1.2.1 From 55cdc874e6519242f7031de034df8d8c00ae283f Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sun, 14 Jul 2013 15:52:57 -0400 Subject: [feature/oauth] Set required scopes on more providers PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/service/amazon.php | 10 +++++++++- phpBB/phpbb/auth/provider/oauth/service/paypal.php | 12 +++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/service/amazon.php b/phpBB/phpbb/auth/provider/oauth/service/amazon.php index 1348bd5ebe..cea4438323 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/amazon.php +++ b/phpBB/phpbb/auth/provider/oauth/service/amazon.php @@ -22,5 +22,13 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_amazon extends phpbb_auth_provider_oauth_service_base { - + /** + * {@inheritdoc} + */ + public function get_auth_scope() + { + return array( + 'profile', + ); + } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/paypal.php b/phpBB/phpbb/auth/provider/oauth/service/paypal.php index 983b008dc3..26038d4fcb 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/paypal.php +++ b/phpBB/phpbb/auth/provider/oauth/service/paypal.php @@ -22,5 +22,15 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_paypal extends phpbb_auth_provider_oauth_service_base { - + /** + * {@inheritdoc} + */ + public function get_auth_scope() + { + return array( + 'openid', + 'profile', + 'email', + ); + } } -- cgit v1.2.1 From 6a2871692cb9b2e9027b026604e8f456f17d1b44 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sun, 14 Jul 2013 16:00:41 -0400 Subject: [feature/oauth] Get service credentials on each OAuth service PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/service/amazon.php | 11 +++++++++++ phpBB/phpbb/auth/provider/oauth/service/bitly.php | 11 ++++++++++- phpBB/phpbb/auth/provider/oauth/service/box.php | 11 ++++++++++- phpBB/phpbb/auth/provider/oauth/service/dropbox.php | 11 ++++++++++- phpBB/phpbb/auth/provider/oauth/service/facebook.php | 11 ++++++++++- phpBB/phpbb/auth/provider/oauth/service/fitbit.php | 13 +++++++++++-- phpBB/phpbb/auth/provider/oauth/service/foursqare.php | 11 ++++++++++- phpBB/phpbb/auth/provider/oauth/service/github.php | 11 +++++++++++ phpBB/phpbb/auth/provider/oauth/service/google.php | 11 +++++++++++ phpBB/phpbb/auth/provider/oauth/service/instagram.php | 11 +++++++++++ phpBB/phpbb/auth/provider/oauth/service/interface.php | 13 +++++++++++++ phpBB/phpbb/auth/provider/oauth/service/linkedin.php | 11 +++++++++++ phpBB/phpbb/auth/provider/oauth/service/microsoft.php | 11 +++++++++++ phpBB/phpbb/auth/provider/oauth/service/paypal.php | 11 +++++++++++ phpBB/phpbb/auth/provider/oauth/service/soundcloud.php | 11 ++++++++++- phpBB/phpbb/auth/provider/oauth/service/tumblr.php | 11 ++++++++++- phpBB/phpbb/auth/provider/oauth/service/twitter.php | 11 ++++++++++- phpBB/phpbb/auth/provider/oauth/service/vkontakte.php | 11 ++++++++++- phpBB/phpbb/auth/provider/oauth/service/yammer.php | 11 ++++++++++- 19 files changed, 201 insertions(+), 12 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/service/amazon.php b/phpBB/phpbb/auth/provider/oauth/service/amazon.php index cea4438323..740add0f3c 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/amazon.php +++ b/phpBB/phpbb/auth/provider/oauth/service/amazon.php @@ -31,4 +31,15 @@ class phpbb_auth_provider_oauth_service_amazon extends phpbb_auth_provider_oauth 'profile', ); } + + /** + * {@inheritdoc} + */ + public function get_service_credentials() + { + return array( + 'key' => $this->config['auth_oauth_amazon_key'], + 'secret' => $this->config['auth_oauth_amazon_secret'], + ); + } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/bitly.php b/phpBB/phpbb/auth/provider/oauth/service/bitly.php index 23769b36a5..1de3183b84 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/bitly.php +++ b/phpBB/phpbb/auth/provider/oauth/service/bitly.php @@ -22,5 +22,14 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_bitly extends phpbb_auth_provider_oauth_service_base { - + /** + * {@inheritdoc} + */ + public function get_service_credentials() + { + return array( + 'key' => $this->config['auth_oauth_bitly_key'], + 'secret' => $this->config['auth_oauth_bitly_secret'], + ); + } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/box.php b/phpBB/phpbb/auth/provider/oauth/service/box.php index cfa788da4d..19e409a943 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/box.php +++ b/phpBB/phpbb/auth/provider/oauth/service/box.php @@ -22,5 +22,14 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_box extends phpbb_auth_provider_oauth_service_base { - + /** + * {@inheritdoc} + */ + public function get_service_credentials() + { + return array( + 'key' => $this->config['auth_oauth_box_key'], + 'secret' => $this->config['auth_oauth_box_secret'], + ); + } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/dropbox.php b/phpBB/phpbb/auth/provider/oauth/service/dropbox.php index 655c4305f3..3b4920bb0e 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/dropbox.php +++ b/phpBB/phpbb/auth/provider/oauth/service/dropbox.php @@ -22,5 +22,14 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_dropbox extends phpbb_auth_provider_oauth_service_base { - + /** + * {@inheritdoc} + */ + public function get_service_credentials() + { + return array( + 'key' => $this->config['auth_oauth_dropbox_key'], + 'secret' => $this->config['auth_oauth_dropbox_secret'], + ); + } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/facebook.php b/phpBB/phpbb/auth/provider/oauth/service/facebook.php index 723c8f09f2..0652028bf8 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/facebook.php +++ b/phpBB/phpbb/auth/provider/oauth/service/facebook.php @@ -22,5 +22,14 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_facebook extends phpbb_auth_provider_oauth_service_base { - + /** + * {@inheritdoc} + */ + public function get_service_credentials() + { + return array( + 'key' => $this->config['auth_oauth_facebook_key'], + 'secret' => $this->config['auth_oauth_facebook_secret'], + ); + } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/fitbit.php b/phpBB/phpbb/auth/provider/oauth/service/fitbit.php index a0f63a40e7..d75b971fcf 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/fitbit.php +++ b/phpBB/phpbb/auth/provider/oauth/service/fitbit.php @@ -20,7 +20,16 @@ if (!defined('IN_PHPBB')) * * @package auth */ -class phpbb_auth_provider_oauth_service_box extends phpbb_auth_provider_oauth_service_base +class phpbb_auth_provider_oauth_service_fitbit extends phpbb_auth_provider_oauth_service_base { - + /** + * {@inheritdoc} + */ + public function get_service_credentials() + { + return array( + 'key' => $this->config['auth_oauth_fitbit_key'], + 'secret' => $this->config['auth_oauth_fitbit_secret'], + ); + } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/foursqare.php b/phpBB/phpbb/auth/provider/oauth/service/foursqare.php index 9eb868b1c4..d03725bcfd 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/foursqare.php +++ b/phpBB/phpbb/auth/provider/oauth/service/foursqare.php @@ -22,5 +22,14 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_foursquare extends phpbb_auth_provider_oauth_service_base { - + /** + * {@inheritdoc} + */ + public function get_service_credentials() + { + return array( + 'key' => $this->config['auth_oauth_foursquare_key'], + 'secret' => $this->config['auth_oauth_foursquare_secret'], + ); + } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/github.php b/phpBB/phpbb/auth/provider/oauth/service/github.php index 1eddb26906..30d23b0e4f 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/github.php +++ b/phpBB/phpbb/auth/provider/oauth/service/github.php @@ -31,4 +31,15 @@ class phpbb_auth_provider_oauth_service_github extends phpbb_auth_provider_oauth 'user', ); } + + /** + * {@inheritdoc} + */ + public function get_service_credentials() + { + return array( + 'key' => $this->config['auth_oauth_github_key'], + 'secret' => $this->config['auth_oauth_github_secret'], + ); + } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/google.php b/phpBB/phpbb/auth/provider/oauth/service/google.php index d72c66ac5e..50cfee86e0 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/google.php +++ b/phpBB/phpbb/auth/provider/oauth/service/google.php @@ -32,4 +32,15 @@ class phpbb_auth_provider_oauth_service_google extends phpbb_auth_provider_oauth 'userinfo_profile', ); } + + /** + * {@inheritdoc} + */ + public function get_service_credentials() + { + return array( + 'key' => $this->config['auth_oauth_google_key'], + 'secret' => $this->config['auth_oauth_google_secret'], + ); + } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/instagram.php b/phpBB/phpbb/auth/provider/oauth/service/instagram.php index c40acf9507..ae30d2d0b6 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/instagram.php +++ b/phpBB/phpbb/auth/provider/oauth/service/instagram.php @@ -31,4 +31,15 @@ class phpbb_auth_provider_oauth_service_instagram extends phpbb_auth_provider_oa 'basic', ); } + + /** + * {@inheritdoc} + */ + public function get_service_credentials() + { + return array( + 'key' => $this->config['auth_oauth_instagram_key'], + 'secret' => $this->config['auth_oauth_instagram_secret'], + ); + } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/interface.php b/phpBB/phpbb/auth/provider/oauth/service/interface.php index c79413ee3a..80f2ee7259 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/interface.php +++ b/phpBB/phpbb/auth/provider/oauth/service/interface.php @@ -28,4 +28,17 @@ interface phpbb_auth_provider_oauth_service_interface * @return array An array of the required scopes */ public function get_auth_scope(); + + /** + * Returns an array containing the service credentials belonging to requested + * service. + * + * @return array An array containing the 'key' and the 'secret' of the + * service in the form: + * array( + * 'key' => string + * 'secret' => string + * ) + */ + public function get_service_credentials(); } diff --git a/phpBB/phpbb/auth/provider/oauth/service/linkedin.php b/phpBB/phpbb/auth/provider/oauth/service/linkedin.php index 118379b4ab..3231270cff 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/linkedin.php +++ b/phpBB/phpbb/auth/provider/oauth/service/linkedin.php @@ -31,4 +31,15 @@ class phpbb_auth_provider_oauth_service_linkedin extends phpbb_auth_provider_oau 'r_basicprofile', ); } + + /** + * {@inheritdoc} + */ + public function get_service_credentials() + { + return array( + 'key' => $this->config['auth_oauth_linkedin_key'], + 'secret' => $this->config['auth_oauth_linkedin_secret'], + ); + } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/microsoft.php b/phpBB/phpbb/auth/provider/oauth/service/microsoft.php index 0ad2a5173b..7fb47f45fc 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/microsoft.php +++ b/phpBB/phpbb/auth/provider/oauth/service/microsoft.php @@ -31,4 +31,15 @@ class phpbb_auth_provider_oauth_service_microsoft extends phpbb_auth_provider_oa 'basic', ); } + + /** + * {@inheritdoc} + */ + public function get_service_credentials() + { + return array( + 'key' => $this->config['auth_oauth_microsoft_key'], + 'secret' => $this->config['auth_oauth_microsoft_secret'], + ); + } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/paypal.php b/phpBB/phpbb/auth/provider/oauth/service/paypal.php index 26038d4fcb..48b361921a 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/paypal.php +++ b/phpBB/phpbb/auth/provider/oauth/service/paypal.php @@ -33,4 +33,15 @@ class phpbb_auth_provider_oauth_service_paypal extends phpbb_auth_provider_oauth 'email', ); } + + /** + * {@inheritdoc} + */ + public function get_service_credentials() + { + return array( + 'key' => $this->config['auth_oauth_paypal_key'], + 'secret' => $this->config['auth_oauth_paypal_secret'], + ); + } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/soundcloud.php b/phpBB/phpbb/auth/provider/oauth/service/soundcloud.php index 0b5de5af20..e000c68a6f 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/soundcloud.php +++ b/phpBB/phpbb/auth/provider/oauth/service/soundcloud.php @@ -22,5 +22,14 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_soundcloud extends phpbb_auth_provider_oauth_service_base { - + /** + * {@inheritdoc} + */ + public function get_service_credentials() + { + return array( + 'key' => $this->config['auth_oauth_soundcloud_key'], + 'secret' => $this->config['auth_oauth_soundcloud_secret'], + ); + } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/tumblr.php b/phpBB/phpbb/auth/provider/oauth/service/tumblr.php index be4871322c..2098cc92e1 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/tumblr.php +++ b/phpBB/phpbb/auth/provider/oauth/service/tumblr.php @@ -22,5 +22,14 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_tumblr extends phpbb_auth_provider_oauth_service_base { - + /** + * {@inheritdoc} + */ + public function get_service_credentials() + { + return array( + 'key' => $this->config['auth_oauth_tumblr_key'], + 'secret' => $this->config['auth_oauth_tumblr_secret'], + ); + } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/twitter.php b/phpBB/phpbb/auth/provider/oauth/service/twitter.php index e58b02fa41..57d07e1c15 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/twitter.php +++ b/phpBB/phpbb/auth/provider/oauth/service/twitter.php @@ -22,5 +22,14 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_twitter extends phpbb_auth_provider_oauth_service_base { - + /** + * {@inheritdoc} + */ + public function get_service_credentials() + { + return array( + 'key' => $this->config['auth_oauth_twitter_key'], + 'secret' => $this->config['auth_oauth_twitter_secret'], + ); + } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/vkontakte.php b/phpBB/phpbb/auth/provider/oauth/service/vkontakte.php index f6398a137d..6b43bf39d8 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/vkontakte.php +++ b/phpBB/phpbb/auth/provider/oauth/service/vkontakte.php @@ -22,5 +22,14 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_vkontakte extends phpbb_auth_provider_oauth_service_base { - + /** + * {@inheritdoc} + */ + public function get_service_credentials() + { + return array( + 'key' => $this->config['auth_oauth_vkontakte_key'], + 'secret' => $this->config['auth_oauth_vkontakte_secret'], + ); + } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/yammer.php b/phpBB/phpbb/auth/provider/oauth/service/yammer.php index 4cbc153329..13c638def7 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/yammer.php +++ b/phpBB/phpbb/auth/provider/oauth/service/yammer.php @@ -22,5 +22,14 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_yammer extends phpbb_auth_provider_oauth_service_base { - + /** + * {@inheritdoc} + */ + public function get_service_credentials() + { + return array( + 'key' => $this->config['auth_oauth_yammer_key'], + 'secret' => $this->config['auth_oauth_yammer_secret'], + ); + } } -- cgit v1.2.1 From a8e60c306d605815abfa0f4204e30466ecfbd539 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sun, 14 Jul 2013 16:01:41 -0400 Subject: [feature/oauth] Remove get_service_credentials() from oauth provider PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 75e8a54ed4..c4908dbf6c 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -147,26 +147,6 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base } } - /** - * Returns an array containing the service credentials belonging to requested - * service. - * - * @param string $service_name The name of the service - * @return array An array containing the 'key' and the 'secret' of the - * service in the form: - * array( - * 'key' => string - * 'secret' => string - * ) - */ - protected function get_service_credentials($service_name) - { - return array( - 'key' => $this->config['auth_oauth_' . $service_name . '_key'], - 'secret' => $this->config['auth_oauth_' . $service_name . '_secret'], - ); - } - /** * Returns the cached current_uri object or creates and caches it if it is * not already created -- cgit v1.2.1 From adc58ba0848a23555044dd76d0b03b9055c81f40 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 14 Jul 2013 16:28:30 -0400 Subject: [ticket/11700] Use a new style constructor for the error collector PHPBB3-11700 --- phpBB/phpbb/error_collector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/error_collector.php b/phpBB/phpbb/error_collector.php index 358da747b8..0a6462d046 100644 --- a/phpBB/phpbb/error_collector.php +++ b/phpBB/phpbb/error_collector.php @@ -19,7 +19,7 @@ class phpbb_error_collector { var $errors; - function phpbb_error_collector() + function __construct() { $this->errors = array(); } -- cgit v1.2.1 From b3e8734a490084d1cb05af97b50748e777663a07 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 14 Jul 2013 16:35:04 -0400 Subject: [ticket/11700] Load the dbms with namespaces PHPBB3-11700 --- phpBB/includes/functions.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 174ba712ba..f0681c9687 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5647,24 +5647,24 @@ function phpbb_convert_30_dbms_to_31($dbms) // true for mysqli class. // However, per the docblock any valid 3.1 driver name should be // recognized by this function, and have priority over 3.0 dbms. - if (class_exists('phpbb_db_driver_' . $dbms)) + if (class_exists('\phpbb\db\driver\\' . $dbms)) { - return 'phpbb_db_driver_' . $dbms; + return '\phpbb\db\driver\\' . $dbms; } if (class_exists($dbms)) { - // Additionally we could check that $dbms extends phpbb_db_driver. + // Additionally we could check that $dbms extends phpbb\db\driver\driver. // http://php.net/manual/en/class.reflectionclass.php // Beware of possible performance issues: // http://stackoverflow.com/questions/294582/php-5-reflection-api-performance // We could check for interface implementation in all paths or - // only when we do not prepend phpbb_db_driver_. + // only when we do not prepend phpbb\db\driver\. /* $reflection = new \ReflectionClass($dbms); - if ($reflection->isSubclassOf('phpbb_db_driver')) + if ($reflection->isSubclassOf('phpbb\db\driver\driver')) { return $dbms; } -- cgit v1.2.1 From 440904a0c8b9fb8da124d879366ae5284532c23e Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sun, 14 Jul 2013 17:03:02 -0400 Subject: [feature/oauth] Add OAuth services to service file PHPBB3-11673 --- phpBB/config/auth_providers.yml | 74 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) (limited to 'phpBB') diff --git a/phpBB/config/auth_providers.yml b/phpBB/config/auth_providers.yml index ead540c953..5282dac5b9 100644 --- a/phpBB/config/auth_providers.yml +++ b/phpBB/config/auth_providers.yml @@ -45,3 +45,77 @@ services: - %tables.auth_provider_oauth% tags: - { name: auth.provider } + auth.provider.oauth.service_collection: + class: phpbb_di_service_collection + arguments: + - @service_container + tags: + - { name: service_collection, tag: auth.provider.oauth.service } + auth.provider.oauth.service.amazon: + class: phpbb_auth_provider_oauth_service_amazon + tages: + - { tag: auth.provider.oauth.service } + auth.provider.oauth.service.bitly: + class: phpbb_auth_provider_oauth_service_bitly + tages: + - { tag: auth.provider.oauth.service } + auth.provider.oauth.service.box: + class: phpbb_auth_provider_oauth_service_box + tages: + - { tag: auth.provider.oauth.service } + auth.provider.oauth.service.dropbox: + class: phpbb_auth_provider_oauth_service_dropbox + tages: + - { tag: auth.provider.oauth.service } + auth.provider.oauth.service.facebook: + class: phpbb_auth_provider_oauth_service_facebook + tages: + - { tag: auth.provider.oauth.service } + auth.provider.oauth.service.fitbit: + class: phpbb_auth_provider_oauth_service_fitbit + tages: + - { tag: auth.provider.oauth.service } + auth.provider.oauth.service.foursquare: + class: phpbb_auth_provider_oauth_service_foursquare + tages: + - { tag: auth.provider.oauth.service } + auth.provider.oauth.service.github: + class: phpbb_auth_provider_oauth_service_github + tages: + - { tag: auth.provider.oauth.service } + auth.provider.oauth.service.instagram: + class: phpbb_auth_provider_oauth_service_instagram + tages: + - { tag: auth.provider.oauth.service } + auth.provider.oauth.service.linkedin: + class: phpbb_auth_provider_oauth_service_linkedin + tages: + - { tag: auth.provider.oauth.service } + auth.provider.oauth.service.microsoft: + class: phpbb_auth_provider_oauth_service_microsoft + tages: + - { tag: auth.provider.oauth.service } + auth.provider.oauth.service.paypal: + class: phpbb_auth_provider_oauth_service_paypal + tages: + - { tag: auth.provider.oauth.service } + auth.provider.oauth.service.soundclod: + class: phpbb_auth_provider_oauth_service_soundcloud + tages: + - { tag: auth.provider.oauth.service } + auth.provider.oauth.service.tumblr: + class: phpbb_auth_provider_oauth_service_tumblr + tages: + - { tag: auth.provider.oauth.service } + auth.provider.oauth.service.twitter: + class: phpbb_auth_provider_oauth_service_twitter + tages: + - { tag: auth.provider.oauth.service } + auth.provider.oauth.service.vkontakte: + class: phpbb_auth_provider_oauth_service_vkontakte + tages: + - { tag: auth.provider.oauth.service } + auth.provider.oauth.service.yammer: + class: phpbb_auth_provider_oauth_service_yammer + tages: + - { tag: auth.provider.oauth.service } -- cgit v1.2.1 From 247a002a144ecfc882f365ad54c63663a9b00090 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sun, 14 Jul 2013 17:23:40 -0400 Subject: [feature/oauth] Add constructors PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/service/amazon.php | 17 +++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/bitly.php | 17 +++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/box.php | 17 +++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/dropbox.php | 17 +++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/facebook.php | 17 +++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/fitbit.php | 17 +++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/foursqare.php | 17 +++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/github.php | 17 +++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/google.php | 17 +++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/instagram.php | 17 +++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/linkedin.php | 17 +++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/microsoft.php | 17 +++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/paypal.php | 17 +++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/soundcloud.php | 17 +++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/tumblr.php | 17 +++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/twitter.php | 17 +++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/vkontakte.php | 17 +++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/yammer.php | 17 +++++++++++++++++ 18 files changed, 306 insertions(+) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/service/amazon.php b/phpBB/phpbb/auth/provider/oauth/service/amazon.php index 740add0f3c..fe27a6110f 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/amazon.php +++ b/phpBB/phpbb/auth/provider/oauth/service/amazon.php @@ -22,6 +22,23 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_amazon extends phpbb_auth_provider_oauth_service_base { + /** + * phpBB config + * + * @var phpbb_config + */ + protected $config; + + /** + * Constructor + * + * @param phpbb_config $config + */ + public function __construct(phpbb_config $config) + { + $this->config = $config; + } + /** * {@inheritdoc} */ diff --git a/phpBB/phpbb/auth/provider/oauth/service/bitly.php b/phpBB/phpbb/auth/provider/oauth/service/bitly.php index 1de3183b84..6b6e08c19a 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/bitly.php +++ b/phpBB/phpbb/auth/provider/oauth/service/bitly.php @@ -22,6 +22,23 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_bitly extends phpbb_auth_provider_oauth_service_base { + /** + * phpBB config + * + * @var phpbb_config + */ + protected $config; + + /** + * Constructor + * + * @param phpbb_config $config + */ + public function __construct(phpbb_config $config) + { + $this->config = $config; + } + /** * {@inheritdoc} */ diff --git a/phpBB/phpbb/auth/provider/oauth/service/box.php b/phpBB/phpbb/auth/provider/oauth/service/box.php index 19e409a943..083212ec2a 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/box.php +++ b/phpBB/phpbb/auth/provider/oauth/service/box.php @@ -22,6 +22,23 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_box extends phpbb_auth_provider_oauth_service_base { + /** + * phpBB config + * + * @var phpbb_config + */ + protected $config; + + /** + * Constructor + * + * @param phpbb_config $config + */ + public function __construct(phpbb_config $config) + { + $this->config = $config; + } + /** * {@inheritdoc} */ diff --git a/phpBB/phpbb/auth/provider/oauth/service/dropbox.php b/phpBB/phpbb/auth/provider/oauth/service/dropbox.php index 3b4920bb0e..4fadcbca11 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/dropbox.php +++ b/phpBB/phpbb/auth/provider/oauth/service/dropbox.php @@ -22,6 +22,23 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_dropbox extends phpbb_auth_provider_oauth_service_base { + /** + * phpBB config + * + * @var phpbb_config + */ + protected $config; + + /** + * Constructor + * + * @param phpbb_config $config + */ + public function __construct(phpbb_config $config) + { + $this->config = $config; + } + /** * {@inheritdoc} */ diff --git a/phpBB/phpbb/auth/provider/oauth/service/facebook.php b/phpBB/phpbb/auth/provider/oauth/service/facebook.php index 0652028bf8..87e8749b55 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/facebook.php +++ b/phpBB/phpbb/auth/provider/oauth/service/facebook.php @@ -22,6 +22,23 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_facebook extends phpbb_auth_provider_oauth_service_base { + /** + * phpBB config + * + * @var phpbb_config + */ + protected $config; + + /** + * Constructor + * + * @param phpbb_config $config + */ + public function __construct(phpbb_config $config) + { + $this->config = $config; + } + /** * {@inheritdoc} */ diff --git a/phpBB/phpbb/auth/provider/oauth/service/fitbit.php b/phpBB/phpbb/auth/provider/oauth/service/fitbit.php index d75b971fcf..bf1aeac98e 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/fitbit.php +++ b/phpBB/phpbb/auth/provider/oauth/service/fitbit.php @@ -22,6 +22,23 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_fitbit extends phpbb_auth_provider_oauth_service_base { + /** + * phpBB config + * + * @var phpbb_config + */ + protected $config; + + /** + * Constructor + * + * @param phpbb_config $config + */ + public function __construct(phpbb_config $config) + { + $this->config = $config; + } + /** * {@inheritdoc} */ diff --git a/phpBB/phpbb/auth/provider/oauth/service/foursqare.php b/phpBB/phpbb/auth/provider/oauth/service/foursqare.php index d03725bcfd..00ebd9889e 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/foursqare.php +++ b/phpBB/phpbb/auth/provider/oauth/service/foursqare.php @@ -22,6 +22,23 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_foursquare extends phpbb_auth_provider_oauth_service_base { + /** + * phpBB config + * + * @var phpbb_config + */ + protected $config; + + /** + * Constructor + * + * @param phpbb_config $config + */ + public function __construct(phpbb_config $config) + { + $this->config = $config; + } + /** * {@inheritdoc} */ diff --git a/phpBB/phpbb/auth/provider/oauth/service/github.php b/phpBB/phpbb/auth/provider/oauth/service/github.php index 30d23b0e4f..91ae0c1287 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/github.php +++ b/phpBB/phpbb/auth/provider/oauth/service/github.php @@ -22,6 +22,23 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_github extends phpbb_auth_provider_oauth_service_base { + /** + * phpBB config + * + * @var phpbb_config + */ + protected $config; + + /** + * Constructor + * + * @param phpbb_config $config + */ + public function __construct(phpbb_config $config) + { + $this->config = $config; + } + /** * {@inheritdoc} */ diff --git a/phpBB/phpbb/auth/provider/oauth/service/google.php b/phpBB/phpbb/auth/provider/oauth/service/google.php index 50cfee86e0..b9b1851424 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/google.php +++ b/phpBB/phpbb/auth/provider/oauth/service/google.php @@ -22,6 +22,23 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_google extends phpbb_auth_provider_oauth_service_base { + /** + * phpBB config + * + * @var phpbb_config + */ + protected $config; + + /** + * Constructor + * + * @param phpbb_config $config + */ + public function __construct(phpbb_config $config) + { + $this->config = $config; + } + /** * {@inheritdoc} */ diff --git a/phpBB/phpbb/auth/provider/oauth/service/instagram.php b/phpBB/phpbb/auth/provider/oauth/service/instagram.php index ae30d2d0b6..0570f79138 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/instagram.php +++ b/phpBB/phpbb/auth/provider/oauth/service/instagram.php @@ -22,6 +22,23 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_instagram extends phpbb_auth_provider_oauth_service_base { + /** + * phpBB config + * + * @var phpbb_config + */ + protected $config; + + /** + * Constructor + * + * @param phpbb_config $config + */ + public function __construct(phpbb_config $config) + { + $this->config = $config; + } + /** * {@inheritdoc} */ diff --git a/phpBB/phpbb/auth/provider/oauth/service/linkedin.php b/phpBB/phpbb/auth/provider/oauth/service/linkedin.php index 3231270cff..faf26132b0 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/linkedin.php +++ b/phpBB/phpbb/auth/provider/oauth/service/linkedin.php @@ -22,6 +22,23 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_linkedin extends phpbb_auth_provider_oauth_service_base { + /** + * phpBB config + * + * @var phpbb_config + */ + protected $config; + + /** + * Constructor + * + * @param phpbb_config $config + */ + public function __construct(phpbb_config $config) + { + $this->config = $config; + } + /** * {@inheritdoc} */ diff --git a/phpBB/phpbb/auth/provider/oauth/service/microsoft.php b/phpBB/phpbb/auth/provider/oauth/service/microsoft.php index 7fb47f45fc..d607f3392d 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/microsoft.php +++ b/phpBB/phpbb/auth/provider/oauth/service/microsoft.php @@ -22,6 +22,23 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_microsoft extends phpbb_auth_provider_oauth_service_base { + /** + * phpBB config + * + * @var phpbb_config + */ + protected $config; + + /** + * Constructor + * + * @param phpbb_config $config + */ + public function __construct(phpbb_config $config) + { + $this->config = $config; + } + /** * {@inheritdoc} */ diff --git a/phpBB/phpbb/auth/provider/oauth/service/paypal.php b/phpBB/phpbb/auth/provider/oauth/service/paypal.php index 48b361921a..8a81c460ce 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/paypal.php +++ b/phpBB/phpbb/auth/provider/oauth/service/paypal.php @@ -22,6 +22,23 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_paypal extends phpbb_auth_provider_oauth_service_base { + /** + * phpBB config + * + * @var phpbb_config + */ + protected $config; + + /** + * Constructor + * + * @param phpbb_config $config + */ + public function __construct(phpbb_config $config) + { + $this->config = $config; + } + /** * {@inheritdoc} */ diff --git a/phpBB/phpbb/auth/provider/oauth/service/soundcloud.php b/phpBB/phpbb/auth/provider/oauth/service/soundcloud.php index e000c68a6f..ac43ea5e48 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/soundcloud.php +++ b/phpBB/phpbb/auth/provider/oauth/service/soundcloud.php @@ -22,6 +22,23 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_soundcloud extends phpbb_auth_provider_oauth_service_base { + /** + * phpBB config + * + * @var phpbb_config + */ + protected $config; + + /** + * Constructor + * + * @param phpbb_config $config + */ + public function __construct(phpbb_config $config) + { + $this->config = $config; + } + /** * {@inheritdoc} */ diff --git a/phpBB/phpbb/auth/provider/oauth/service/tumblr.php b/phpBB/phpbb/auth/provider/oauth/service/tumblr.php index 2098cc92e1..9b6d2e2f5e 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/tumblr.php +++ b/phpBB/phpbb/auth/provider/oauth/service/tumblr.php @@ -22,6 +22,23 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_tumblr extends phpbb_auth_provider_oauth_service_base { + /** + * phpBB config + * + * @var phpbb_config + */ + protected $config; + + /** + * Constructor + * + * @param phpbb_config $config + */ + public function __construct(phpbb_config $config) + { + $this->config = $config; + } + /** * {@inheritdoc} */ diff --git a/phpBB/phpbb/auth/provider/oauth/service/twitter.php b/phpBB/phpbb/auth/provider/oauth/service/twitter.php index 57d07e1c15..23dbdbb6c2 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/twitter.php +++ b/phpBB/phpbb/auth/provider/oauth/service/twitter.php @@ -22,6 +22,23 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_twitter extends phpbb_auth_provider_oauth_service_base { + /** + * phpBB config + * + * @var phpbb_config + */ + protected $config; + + /** + * Constructor + * + * @param phpbb_config $config + */ + public function __construct(phpbb_config $config) + { + $this->config = $config; + } + /** * {@inheritdoc} */ diff --git a/phpBB/phpbb/auth/provider/oauth/service/vkontakte.php b/phpBB/phpbb/auth/provider/oauth/service/vkontakte.php index 6b43bf39d8..8a328b234f 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/vkontakte.php +++ b/phpBB/phpbb/auth/provider/oauth/service/vkontakte.php @@ -22,6 +22,23 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_vkontakte extends phpbb_auth_provider_oauth_service_base { + /** + * phpBB config + * + * @var phpbb_config + */ + protected $config; + + /** + * Constructor + * + * @param phpbb_config $config + */ + public function __construct(phpbb_config $config) + { + $this->config = $config; + } + /** * {@inheritdoc} */ diff --git a/phpBB/phpbb/auth/provider/oauth/service/yammer.php b/phpBB/phpbb/auth/provider/oauth/service/yammer.php index 13c638def7..fe14f13077 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/yammer.php +++ b/phpBB/phpbb/auth/provider/oauth/service/yammer.php @@ -22,6 +22,23 @@ if (!defined('IN_PHPBB')) */ class phpbb_auth_provider_oauth_service_yammer extends phpbb_auth_provider_oauth_service_base { + /** + * phpBB config + * + * @var phpbb_config + */ + protected $config; + + /** + * Constructor + * + * @param phpbb_config $config + */ + public function __construct(phpbb_config $config) + { + $this->config = $config; + } + /** * {@inheritdoc} */ -- cgit v1.2.1 From 80c5a4252569b4b219904f16069ca319670c8555 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sun, 14 Jul 2013 17:26:09 -0400 Subject: [feature/oauth] Add constructor arguments to services file PHPBB3-11673 --- phpBB/config/auth_providers.yml | 68 ++++++++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 17 deletions(-) (limited to 'phpBB') diff --git a/phpBB/config/auth_providers.yml b/phpBB/config/auth_providers.yml index 5282dac5b9..0696b01001 100644 --- a/phpBB/config/auth_providers.yml +++ b/phpBB/config/auth_providers.yml @@ -53,69 +53,103 @@ services: - { name: service_collection, tag: auth.provider.oauth.service } auth.provider.oauth.service.amazon: class: phpbb_auth_provider_oauth_service_amazon - tages: + arguments: + - @config + tags: - { tag: auth.provider.oauth.service } auth.provider.oauth.service.bitly: class: phpbb_auth_provider_oauth_service_bitly - tages: + arguments: + - @config + tags: - { tag: auth.provider.oauth.service } auth.provider.oauth.service.box: class: phpbb_auth_provider_oauth_service_box - tages: + arguments: + - @config + tags: - { tag: auth.provider.oauth.service } auth.provider.oauth.service.dropbox: class: phpbb_auth_provider_oauth_service_dropbox - tages: + arguments: + - @config + tags: - { tag: auth.provider.oauth.service } auth.provider.oauth.service.facebook: class: phpbb_auth_provider_oauth_service_facebook - tages: + arguments: + - @config + tags: - { tag: auth.provider.oauth.service } auth.provider.oauth.service.fitbit: class: phpbb_auth_provider_oauth_service_fitbit - tages: + arguments: + - @config + tags: - { tag: auth.provider.oauth.service } auth.provider.oauth.service.foursquare: class: phpbb_auth_provider_oauth_service_foursquare - tages: + arguments: + - @config + tags: - { tag: auth.provider.oauth.service } auth.provider.oauth.service.github: class: phpbb_auth_provider_oauth_service_github - tages: + arguments: + - @config + tags: - { tag: auth.provider.oauth.service } auth.provider.oauth.service.instagram: class: phpbb_auth_provider_oauth_service_instagram - tages: + arguments: + - @config + tags: - { tag: auth.provider.oauth.service } auth.provider.oauth.service.linkedin: class: phpbb_auth_provider_oauth_service_linkedin - tages: + arguments: + - @config + tags: - { tag: auth.provider.oauth.service } auth.provider.oauth.service.microsoft: class: phpbb_auth_provider_oauth_service_microsoft - tages: + arguments: + - @config + tags: - { tag: auth.provider.oauth.service } auth.provider.oauth.service.paypal: class: phpbb_auth_provider_oauth_service_paypal - tages: + arguments: + - @config + tags: - { tag: auth.provider.oauth.service } auth.provider.oauth.service.soundclod: class: phpbb_auth_provider_oauth_service_soundcloud - tages: + arguments: + - @config + tags: - { tag: auth.provider.oauth.service } auth.provider.oauth.service.tumblr: class: phpbb_auth_provider_oauth_service_tumblr - tages: + arguments: + - @config + tags: - { tag: auth.provider.oauth.service } auth.provider.oauth.service.twitter: class: phpbb_auth_provider_oauth_service_twitter - tages: + arguments: + - @config + tags: - { tag: auth.provider.oauth.service } auth.provider.oauth.service.vkontakte: class: phpbb_auth_provider_oauth_service_vkontakte - tages: + arguments: + - @config + tags: - { tag: auth.provider.oauth.service } auth.provider.oauth.service.yammer: class: phpbb_auth_provider_oauth_service_yammer - tages: + arguments: + - @config + tags: - { tag: auth.provider.oauth.service } -- cgit v1.2.1 From 0156bac3e2121cf23d0fef048233257fcb2c0d25 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sun, 14 Jul 2013 17:40:09 -0400 Subject: [feature/oauth] Update auth provider oauth to take in service providers PHPBB3-11673 --- phpBB/config/auth_providers.yml | 1 + phpBB/phpbb/auth/provider/oauth/oauth.php | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/config/auth_providers.yml b/phpBB/config/auth_providers.yml index 0696b01001..a781ad2999 100644 --- a/phpBB/config/auth_providers.yml +++ b/phpBB/config/auth_providers.yml @@ -43,6 +43,7 @@ services: - @request - @user - %tables.auth_provider_oauth% + - @auth.provider.oauth.service_collection tags: - { name: auth.provider } auth.provider.oauth.service_collection: diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index c4908dbf6c..4db9946e50 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -67,6 +67,13 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base */ protected $services; + /** + * All OAuth service providers + * + * @var array Contains phpbb_auth_provider_oauth_service_interface + */ + protected $service_providers; + /** * Cached current uri object * @@ -82,14 +89,16 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base * @param phpbb_request $request * @param phpbb_user $user * @param string $auth_provider_oauth_table + * @param phpbb_auth_provider_oauth_service_interface $service_providers */ - public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_request $request, phpbb_user $user, $auth_provider_oauth_table) + public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_request $request, phpbb_user $user, $auth_provider_oauth_table, phpbb_auth_provider_oauth_service_interface $service_providers) { $this->db = $db; $this->config = $config; $this->request = $request; $this->user = $user; $this->auth_provider_oauth_table = $auth_provider_oauth_table; + $this->service_providers = $service_providers; $this->services = array(); } -- cgit v1.2.1 From eb17462f906a9010ca193b2dd28375f2fcc38c03 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sun, 14 Jul 2013 17:45:05 -0400 Subject: [feature/oauth] Fix typo PHPBB3-11673 --- phpBB/config/auth_providers.yml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'phpBB') diff --git a/phpBB/config/auth_providers.yml b/phpBB/config/auth_providers.yml index a781ad2999..0d2075bc87 100644 --- a/phpBB/config/auth_providers.yml +++ b/phpBB/config/auth_providers.yml @@ -57,100 +57,100 @@ services: arguments: - @config tags: - - { tag: auth.provider.oauth.service } + - { name: auth.provider.oauth.service } auth.provider.oauth.service.bitly: class: phpbb_auth_provider_oauth_service_bitly arguments: - @config tags: - - { tag: auth.provider.oauth.service } + - { name: auth.provider.oauth.service } auth.provider.oauth.service.box: class: phpbb_auth_provider_oauth_service_box arguments: - @config tags: - - { tag: auth.provider.oauth.service } + - { name: auth.provider.oauth.service } auth.provider.oauth.service.dropbox: class: phpbb_auth_provider_oauth_service_dropbox arguments: - @config tags: - - { tag: auth.provider.oauth.service } + - { name: auth.provider.oauth.service } auth.provider.oauth.service.facebook: class: phpbb_auth_provider_oauth_service_facebook arguments: - @config tags: - - { tag: auth.provider.oauth.service } + - { name: auth.provider.oauth.service } auth.provider.oauth.service.fitbit: class: phpbb_auth_provider_oauth_service_fitbit arguments: - @config tags: - - { tag: auth.provider.oauth.service } + - { name: auth.provider.oauth.service } auth.provider.oauth.service.foursquare: class: phpbb_auth_provider_oauth_service_foursquare arguments: - @config tags: - - { tag: auth.provider.oauth.service } + - { name: auth.provider.oauth.service } auth.provider.oauth.service.github: class: phpbb_auth_provider_oauth_service_github arguments: - @config tags: - - { tag: auth.provider.oauth.service } + - { name: auth.provider.oauth.service } auth.provider.oauth.service.instagram: class: phpbb_auth_provider_oauth_service_instagram arguments: - @config tags: - - { tag: auth.provider.oauth.service } + - { name: auth.provider.oauth.service } auth.provider.oauth.service.linkedin: class: phpbb_auth_provider_oauth_service_linkedin arguments: - @config tags: - - { tag: auth.provider.oauth.service } + - { name: auth.provider.oauth.service } auth.provider.oauth.service.microsoft: class: phpbb_auth_provider_oauth_service_microsoft arguments: - @config tags: - - { tag: auth.provider.oauth.service } + - { name: auth.provider.oauth.service } auth.provider.oauth.service.paypal: class: phpbb_auth_provider_oauth_service_paypal arguments: - @config tags: - - { tag: auth.provider.oauth.service } + - { name: auth.provider.oauth.service } auth.provider.oauth.service.soundclod: class: phpbb_auth_provider_oauth_service_soundcloud arguments: - @config tags: - - { tag: auth.provider.oauth.service } + - { name: auth.provider.oauth.service } auth.provider.oauth.service.tumblr: class: phpbb_auth_provider_oauth_service_tumblr arguments: - @config tags: - - { tag: auth.provider.oauth.service } + - { name: auth.provider.oauth.service } auth.provider.oauth.service.twitter: class: phpbb_auth_provider_oauth_service_twitter arguments: - @config tags: - - { tag: auth.provider.oauth.service } + - { name: auth.provider.oauth.service } auth.provider.oauth.service.vkontakte: class: phpbb_auth_provider_oauth_service_vkontakte arguments: - @config tags: - - { tag: auth.provider.oauth.service } + - { name: auth.provider.oauth.service } auth.provider.oauth.service.yammer: class: phpbb_auth_provider_oauth_service_yammer arguments: - @config tags: - - { tag: auth.provider.oauth.service } + - { name: auth.provider.oauth.service } -- cgit v1.2.1 From 6e1c522bdd0e3c67786656a866219c57b7b1e4dc Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 15 Jul 2013 14:57:00 -0400 Subject: [feature/oauth] Update oauth to reflect recent changes PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 4db9946e50..3ef6d8c934 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -109,7 +109,8 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base { // Requst the name of the OAuth service $service_name = $this->request->variable('oauth_service', '', false, phpbb_request_interface::POST); - if ($service_name === '') + $service_name = strtolower($service_name); + if ($service_name === '' && isset($this->services[$service_name])) { return array( 'status' => LOGIN_ERROR_EXTERNAL_AUTH, @@ -120,18 +121,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base } // Get the service credentials for the given service - $service_credentials = $this->get_credentials($service_name); - - // Check that the service has settings - if ($service_credentials['key'] == false || $service_credentials['secret'] == false) - { - return array( - 'status' => LOGIN_ERROR_EXTERNAL_AUTH, - // TODO: change error message - 'error_msg' => 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE', - 'user_row' => array('user_id' => ANONYMOUS), - ); - } + $service_credentials = $this->services[$service_name]->get_credentials($service_name); $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_table); $service = $this->get_service($service_name, $storage, $service_credentials, $this->get_scopes($service_name)); -- cgit v1.2.1 From 8641127da5dd71d4f8fc7acc6ca0b2a34a4ede56 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 15 Jul 2013 15:06:54 -0400 Subject: [feature/oauth] Correct function call PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 3ef6d8c934..9ee689172c 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -121,10 +121,10 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base } // Get the service credentials for the given service - $service_credentials = $this->services[$service_name]->get_credentials($service_name); + $service_credentials = $this->services[$service_name]->get_credentials(); $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_table); - $service = $this->get_service($service_name, $storage, $service_credentials, $this->get_scopes($service_name)); + $service = $this->get_service($service_name, $storage, $service_credentials, $this->services[$service_name]->get_auth_scope()); if ($this->request->is_set('code', phpbb_request_interface::GET)) { -- cgit v1.2.1 From 47b998ae486ebe9c0f9df5be4e3d836b31f2c7a3 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 15 Jul 2013 15:21:20 -0400 Subject: [feature/oauth] Define method to perform login actions for a provider PHPB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 11 ++--------- phpBB/phpbb/auth/provider/oauth/service/base.php | 23 ++++++++++++++++++++++ .../auth/provider/oauth/service/interface.php | 14 +++++++++++++ 3 files changed, 39 insertions(+), 9 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 9ee689172c..fc6fce3db0 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -128,15 +128,8 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base if ($this->request->is_set('code', phpbb_request_interface::GET)) { - // This was a callback request from the service provider - $service->requestAccessToken( $_GET['code'] ); - - // Send a request with it - $path = $this->get_path($service_name); - if ($path) - { - $result = json_decode( $service->request($path), true ); - } + $this->services[$service_name]->set_external_service_provider($service); + $result = $this->services[$service_name]->perform_auth_login(); // Perform authentication } else { diff --git a/phpBB/phpbb/auth/provider/oauth/service/base.php b/phpBB/phpbb/auth/provider/oauth/service/base.php index 98a1fa16e4..d59199f987 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/base.php +++ b/phpBB/phpbb/auth/provider/oauth/service/base.php @@ -22,6 +22,21 @@ if (!defined('IN_PHPBB')) */ abstract class phpbb_auth_provider_oauth_service_base implements phpbb_auth_provider_oauth_service_interface { + /** + * External OAuth service provider + * + * @var \OAuth\Common\Service\ServiceInterface + */ + protected $service_provider; + + /** + * {@inheritdoc} + */ + public function get_external_service_provider() + { + return $this->service_provider; + } + /** * {@inheritdoc} */ @@ -29,4 +44,12 @@ abstract class phpbb_auth_provider_oauth_service_base implements phpbb_auth_prov { return array(); } + + /** + * {@inheritdoc} + */ + public function set_external_service_provider(\OAuth\Common\Service\ServiceInterface $service_provider) + { + $this->service_provider = $service; + } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/interface.php b/phpBB/phpbb/auth/provider/oauth/service/interface.php index 80f2ee7259..5893bc1740 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/interface.php +++ b/phpBB/phpbb/auth/provider/oauth/service/interface.php @@ -29,6 +29,13 @@ interface phpbb_auth_provider_oauth_service_interface */ public function get_auth_scope(); + /** + * Returns the external library service provider once it has been set + * + * @param \OAuth\Common\Service\ServiceInterface|null + */ + public function get_external_service_provider(); + /** * Returns an array containing the service credentials belonging to requested * service. @@ -41,4 +48,11 @@ interface phpbb_auth_provider_oauth_service_interface * ) */ public function get_service_credentials(); + + /** + * Sets the external library service provider + * + * @param \OAuth\Common\Service\ServiceInterface $service + */ + public function set_external_service_provider(\OAuth\Common\Service\ServiceInterface $service_provider); } -- cgit v1.2.1 From e9bf2bf09a2b1fcee0d206b691a739600fee49e0 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 15 Jul 2013 15:28:13 -0400 Subject: [feature/oauth] Update interface appropriately PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/service/interface.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/service/interface.php b/phpBB/phpbb/auth/provider/oauth/service/interface.php index 5893bc1740..4d06606f49 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/interface.php +++ b/phpBB/phpbb/auth/provider/oauth/service/interface.php @@ -49,6 +49,13 @@ interface phpbb_auth_provider_oauth_service_interface */ public function get_service_credentials(); + /** + * Returns the results of the authentication in json format + * + * @return type The results of the authentication action in json format. + */ + public function perform_auth_login(); + /** * Sets the external library service provider * -- cgit v1.2.1 From 469879716d86757c2e583bc746bebaa39cd630ef Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 18 Jul 2013 11:51:10 -0400 Subject: [feature/oauth] Bitly authentication method, no user_id association PHPBB3-11673 --- phpBB/config/auth_providers.yml | 1 + phpBB/phpbb/auth/provider/oauth/service/bitly.php | 31 ++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/config/auth_providers.yml b/phpBB/config/auth_providers.yml index 0d2075bc87..74f674a1f9 100644 --- a/phpBB/config/auth_providers.yml +++ b/phpBB/config/auth_providers.yml @@ -62,6 +62,7 @@ services: class: phpbb_auth_provider_oauth_service_bitly arguments: - @config + - @request tags: - { name: auth.provider.oauth.service } auth.provider.oauth.service.box: diff --git a/phpBB/phpbb/auth/provider/oauth/service/bitly.php b/phpBB/phpbb/auth/provider/oauth/service/bitly.php index 6b6e08c19a..cbfad3d852 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/bitly.php +++ b/phpBB/phpbb/auth/provider/oauth/service/bitly.php @@ -29,14 +29,23 @@ class phpbb_auth_provider_oauth_service_bitly extends phpbb_auth_provider_oauth_ */ protected $config; + /** + * phpBB request + * + * @var phpbb_request + */ + protected $request; + /** * Constructor * * @param phpbb_config $config + * @param phpbb_request $request */ - public function __construct(phpbb_config $config) + public function __construct(phpbb_config $config, phpbb_request $request) { $this->config = $config; + $this->request = $request; } /** @@ -49,4 +58,24 @@ class phpbb_auth_provider_oauth_service_bitly extends phpbb_auth_provider_oauth_ 'secret' => $this->config['auth_oauth_bitly_secret'], ); } + + /** + * {@inheritdoc} + */ + public function perform_auth_login() + { + if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Bitly)) + { + // TODO: make exception class and use language constant + throw new Exception('Invalid service provider type'); + } + + // This was a callback request from bitly, get the token + $this->service_provider->requestAccessToken( $this->request->variable('code', '') ); + + // Send a request with it + $result = json_decode( $this->service_provider->request('user/info'), true ); + + // Get the user id + } } -- cgit v1.2.1 From fe9428b7250fce4cee0d601591e3fac117911d2e Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 18 Jul 2013 12:12:14 -0400 Subject: [feature/oauth] Create means to associate phpBB account with external PHPBB3-11673 --- phpBB/develop/create_schema_files.php | 14 +++++++++++++- phpBB/phpbb/auth/provider/oauth/service/bitly.php | 3 ++- phpBB/phpbb/auth/provider/oauth/service/interface.php | 3 ++- phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php | 13 ++++++++++++- 4 files changed, 29 insertions(+), 4 deletions(-) (limited to 'phpBB') diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index c7d3cc4106..2cfe336511 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -923,7 +923,7 @@ function get_schema_struct() ), ); - $schemda_data['auth_provider_oauth'] = array( + $schemda_data['auth_provider_oauth_token_storage'] = array( 'COLUMNS' => array( 'user_id' => array('UINT', 0), // phpbb_users.user_id 'session_id' => array('CHAR:32', ''), // phpbb_sessions.session_id used only when user_id not set @@ -936,6 +936,18 @@ function get_schema_struct() ), ); + $schemda_data['auth_provider_oauth_account_assoc'] = array( + 'COLUMNS' => array( + 'user_id' => array('UINT', 0), + 'oauth_provider' => array('VCHAR'), + 'oauth_provider_id' => array('TEXT_UNI'), + ), + 'PRIMARY_KEY' => array( + 'user_id', + 'oauth_provider', + ), + ); + $schema_data['phpbb_banlist'] = array( 'COLUMNS' => array( 'ban_id' => array('UINT', NULL, 'auto_increment'), diff --git a/phpBB/phpbb/auth/provider/oauth/service/bitly.php b/phpBB/phpbb/auth/provider/oauth/service/bitly.php index cbfad3d852..b6b99c0850 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/bitly.php +++ b/phpBB/phpbb/auth/provider/oauth/service/bitly.php @@ -76,6 +76,7 @@ class phpbb_auth_provider_oauth_service_bitly extends phpbb_auth_provider_oauth_ // Send a request with it $result = json_decode( $this->service_provider->request('user/info'), true ); - // Get the user id + // Return the unique identifier returned from bitly + return $result['data']['login']; } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/interface.php b/phpBB/phpbb/auth/provider/oauth/service/interface.php index 4d06606f49..a69148695d 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/interface.php +++ b/phpBB/phpbb/auth/provider/oauth/service/interface.php @@ -52,7 +52,8 @@ interface phpbb_auth_provider_oauth_service_interface /** * Returns the results of the authentication in json format * - * @return type The results of the authentication action in json format. + * @return string The unique identifier returned by the service provider + * that is used to authenticate the user with phpBB. */ public function perform_auth_login(); diff --git a/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php b/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php index 92da42ba31..86e446e48e 100644 --- a/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php +++ b/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php @@ -18,7 +18,7 @@ class phpbb_db_migration_data_310_auth_provider_oauth extends phpbb_db_migration { return array( 'add_tables' => array( - $this->table_prefix . 'auth_provider_oauth' => array( + $this->table_prefix . 'auth_provider_oauth_token_storage' => array( 'COLUMNS' => array( 'user_id' => array('UINT', 0), // phpbb_users.user_id 'session_id' => array('CHAR:32', ''), // phpbb_sessions.session_id used only when user_id not set @@ -30,6 +30,17 @@ class phpbb_db_migration_data_310_auth_provider_oauth extends phpbb_db_migration 'oauth_provider' => array('INDEX', 'oauth_provider'), ), ), + $this->table_prefix . 'auth_provider_oauth_account_assoc' => array( + 'COLUMNS' => array( + 'user_id' => array('UINT', 0), + 'oauth_provider' => array('VCHAR'), + 'oauth_provider_id' => array('TEXT_UNI'), + ), + 'PRIMARY_KEY' => array( + 'user_id', + 'oauth_provider', + ), + ), ), ); } -- cgit v1.2.1 From 662b8fdcec2ce6127bd97fbaf3e15db8d4de2170 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 18 Jul 2013 12:21:28 -0400 Subject: [feature/oauth] Remove OAuth providers to make PR smaller PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/service/amazon.php | 62 --------------------- phpBB/phpbb/auth/provider/oauth/service/box.php | 52 ------------------ .../phpbb/auth/provider/oauth/service/dropbox.php | 52 ------------------ phpBB/phpbb/auth/provider/oauth/service/fitbit.php | 52 ------------------ .../auth/provider/oauth/service/foursqare.php | 52 ------------------ phpBB/phpbb/auth/provider/oauth/service/github.php | 62 --------------------- .../auth/provider/oauth/service/instagram.php | 62 --------------------- .../phpbb/auth/provider/oauth/service/linkedin.php | 62 --------------------- .../auth/provider/oauth/service/microsoft.php | 62 --------------------- phpBB/phpbb/auth/provider/oauth/service/paypal.php | 64 ---------------------- .../auth/provider/oauth/service/soundcloud.php | 52 ------------------ phpBB/phpbb/auth/provider/oauth/service/tumblr.php | 52 ------------------ .../phpbb/auth/provider/oauth/service/twitter.php | 52 ------------------ .../auth/provider/oauth/service/vkontakte.php | 52 ------------------ phpBB/phpbb/auth/provider/oauth/service/yammer.php | 52 ------------------ 15 files changed, 842 deletions(-) delete mode 100644 phpBB/phpbb/auth/provider/oauth/service/amazon.php delete mode 100644 phpBB/phpbb/auth/provider/oauth/service/box.php delete mode 100644 phpBB/phpbb/auth/provider/oauth/service/dropbox.php delete mode 100644 phpBB/phpbb/auth/provider/oauth/service/fitbit.php delete mode 100644 phpBB/phpbb/auth/provider/oauth/service/foursqare.php delete mode 100644 phpBB/phpbb/auth/provider/oauth/service/github.php delete mode 100644 phpBB/phpbb/auth/provider/oauth/service/instagram.php delete mode 100644 phpBB/phpbb/auth/provider/oauth/service/linkedin.php delete mode 100644 phpBB/phpbb/auth/provider/oauth/service/microsoft.php delete mode 100644 phpBB/phpbb/auth/provider/oauth/service/paypal.php delete mode 100644 phpBB/phpbb/auth/provider/oauth/service/soundcloud.php delete mode 100644 phpBB/phpbb/auth/provider/oauth/service/tumblr.php delete mode 100644 phpBB/phpbb/auth/provider/oauth/service/twitter.php delete mode 100644 phpBB/phpbb/auth/provider/oauth/service/vkontakte.php delete mode 100644 phpBB/phpbb/auth/provider/oauth/service/yammer.php (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/service/amazon.php b/phpBB/phpbb/auth/provider/oauth/service/amazon.php deleted file mode 100644 index fe27a6110f..0000000000 --- a/phpBB/phpbb/auth/provider/oauth/service/amazon.php +++ /dev/null @@ -1,62 +0,0 @@ -config = $config; - } - - /** - * {@inheritdoc} - */ - public function get_auth_scope() - { - return array( - 'profile', - ); - } - - /** - * {@inheritdoc} - */ - public function get_service_credentials() - { - return array( - 'key' => $this->config['auth_oauth_amazon_key'], - 'secret' => $this->config['auth_oauth_amazon_secret'], - ); - } -} diff --git a/phpBB/phpbb/auth/provider/oauth/service/box.php b/phpBB/phpbb/auth/provider/oauth/service/box.php deleted file mode 100644 index 083212ec2a..0000000000 --- a/phpBB/phpbb/auth/provider/oauth/service/box.php +++ /dev/null @@ -1,52 +0,0 @@ -config = $config; - } - - /** - * {@inheritdoc} - */ - public function get_service_credentials() - { - return array( - 'key' => $this->config['auth_oauth_box_key'], - 'secret' => $this->config['auth_oauth_box_secret'], - ); - } -} diff --git a/phpBB/phpbb/auth/provider/oauth/service/dropbox.php b/phpBB/phpbb/auth/provider/oauth/service/dropbox.php deleted file mode 100644 index 4fadcbca11..0000000000 --- a/phpBB/phpbb/auth/provider/oauth/service/dropbox.php +++ /dev/null @@ -1,52 +0,0 @@ -config = $config; - } - - /** - * {@inheritdoc} - */ - public function get_service_credentials() - { - return array( - 'key' => $this->config['auth_oauth_dropbox_key'], - 'secret' => $this->config['auth_oauth_dropbox_secret'], - ); - } -} diff --git a/phpBB/phpbb/auth/provider/oauth/service/fitbit.php b/phpBB/phpbb/auth/provider/oauth/service/fitbit.php deleted file mode 100644 index bf1aeac98e..0000000000 --- a/phpBB/phpbb/auth/provider/oauth/service/fitbit.php +++ /dev/null @@ -1,52 +0,0 @@ -config = $config; - } - - /** - * {@inheritdoc} - */ - public function get_service_credentials() - { - return array( - 'key' => $this->config['auth_oauth_fitbit_key'], - 'secret' => $this->config['auth_oauth_fitbit_secret'], - ); - } -} diff --git a/phpBB/phpbb/auth/provider/oauth/service/foursqare.php b/phpBB/phpbb/auth/provider/oauth/service/foursqare.php deleted file mode 100644 index 00ebd9889e..0000000000 --- a/phpBB/phpbb/auth/provider/oauth/service/foursqare.php +++ /dev/null @@ -1,52 +0,0 @@ -config = $config; - } - - /** - * {@inheritdoc} - */ - public function get_service_credentials() - { - return array( - 'key' => $this->config['auth_oauth_foursquare_key'], - 'secret' => $this->config['auth_oauth_foursquare_secret'], - ); - } -} diff --git a/phpBB/phpbb/auth/provider/oauth/service/github.php b/phpBB/phpbb/auth/provider/oauth/service/github.php deleted file mode 100644 index 91ae0c1287..0000000000 --- a/phpBB/phpbb/auth/provider/oauth/service/github.php +++ /dev/null @@ -1,62 +0,0 @@ -config = $config; - } - - /** - * {@inheritdoc} - */ - public function get_auth_scope() - { - return array( - 'user', - ); - } - - /** - * {@inheritdoc} - */ - public function get_service_credentials() - { - return array( - 'key' => $this->config['auth_oauth_github_key'], - 'secret' => $this->config['auth_oauth_github_secret'], - ); - } -} diff --git a/phpBB/phpbb/auth/provider/oauth/service/instagram.php b/phpBB/phpbb/auth/provider/oauth/service/instagram.php deleted file mode 100644 index 0570f79138..0000000000 --- a/phpBB/phpbb/auth/provider/oauth/service/instagram.php +++ /dev/null @@ -1,62 +0,0 @@ -config = $config; - } - - /** - * {@inheritdoc} - */ - public function get_auth_scope() - { - return array( - 'basic', - ); - } - - /** - * {@inheritdoc} - */ - public function get_service_credentials() - { - return array( - 'key' => $this->config['auth_oauth_instagram_key'], - 'secret' => $this->config['auth_oauth_instagram_secret'], - ); - } -} diff --git a/phpBB/phpbb/auth/provider/oauth/service/linkedin.php b/phpBB/phpbb/auth/provider/oauth/service/linkedin.php deleted file mode 100644 index faf26132b0..0000000000 --- a/phpBB/phpbb/auth/provider/oauth/service/linkedin.php +++ /dev/null @@ -1,62 +0,0 @@ -config = $config; - } - - /** - * {@inheritdoc} - */ - public function get_auth_scope() - { - return array( - 'r_basicprofile', - ); - } - - /** - * {@inheritdoc} - */ - public function get_service_credentials() - { - return array( - 'key' => $this->config['auth_oauth_linkedin_key'], - 'secret' => $this->config['auth_oauth_linkedin_secret'], - ); - } -} diff --git a/phpBB/phpbb/auth/provider/oauth/service/microsoft.php b/phpBB/phpbb/auth/provider/oauth/service/microsoft.php deleted file mode 100644 index d607f3392d..0000000000 --- a/phpBB/phpbb/auth/provider/oauth/service/microsoft.php +++ /dev/null @@ -1,62 +0,0 @@ -config = $config; - } - - /** - * {@inheritdoc} - */ - public function get_auth_scope() - { - return array( - 'basic', - ); - } - - /** - * {@inheritdoc} - */ - public function get_service_credentials() - { - return array( - 'key' => $this->config['auth_oauth_microsoft_key'], - 'secret' => $this->config['auth_oauth_microsoft_secret'], - ); - } -} diff --git a/phpBB/phpbb/auth/provider/oauth/service/paypal.php b/phpBB/phpbb/auth/provider/oauth/service/paypal.php deleted file mode 100644 index 8a81c460ce..0000000000 --- a/phpBB/phpbb/auth/provider/oauth/service/paypal.php +++ /dev/null @@ -1,64 +0,0 @@ -config = $config; - } - - /** - * {@inheritdoc} - */ - public function get_auth_scope() - { - return array( - 'openid', - 'profile', - 'email', - ); - } - - /** - * {@inheritdoc} - */ - public function get_service_credentials() - { - return array( - 'key' => $this->config['auth_oauth_paypal_key'], - 'secret' => $this->config['auth_oauth_paypal_secret'], - ); - } -} diff --git a/phpBB/phpbb/auth/provider/oauth/service/soundcloud.php b/phpBB/phpbb/auth/provider/oauth/service/soundcloud.php deleted file mode 100644 index ac43ea5e48..0000000000 --- a/phpBB/phpbb/auth/provider/oauth/service/soundcloud.php +++ /dev/null @@ -1,52 +0,0 @@ -config = $config; - } - - /** - * {@inheritdoc} - */ - public function get_service_credentials() - { - return array( - 'key' => $this->config['auth_oauth_soundcloud_key'], - 'secret' => $this->config['auth_oauth_soundcloud_secret'], - ); - } -} diff --git a/phpBB/phpbb/auth/provider/oauth/service/tumblr.php b/phpBB/phpbb/auth/provider/oauth/service/tumblr.php deleted file mode 100644 index 9b6d2e2f5e..0000000000 --- a/phpBB/phpbb/auth/provider/oauth/service/tumblr.php +++ /dev/null @@ -1,52 +0,0 @@ -config = $config; - } - - /** - * {@inheritdoc} - */ - public function get_service_credentials() - { - return array( - 'key' => $this->config['auth_oauth_tumblr_key'], - 'secret' => $this->config['auth_oauth_tumblr_secret'], - ); - } -} diff --git a/phpBB/phpbb/auth/provider/oauth/service/twitter.php b/phpBB/phpbb/auth/provider/oauth/service/twitter.php deleted file mode 100644 index 23dbdbb6c2..0000000000 --- a/phpBB/phpbb/auth/provider/oauth/service/twitter.php +++ /dev/null @@ -1,52 +0,0 @@ -config = $config; - } - - /** - * {@inheritdoc} - */ - public function get_service_credentials() - { - return array( - 'key' => $this->config['auth_oauth_twitter_key'], - 'secret' => $this->config['auth_oauth_twitter_secret'], - ); - } -} diff --git a/phpBB/phpbb/auth/provider/oauth/service/vkontakte.php b/phpBB/phpbb/auth/provider/oauth/service/vkontakte.php deleted file mode 100644 index 8a328b234f..0000000000 --- a/phpBB/phpbb/auth/provider/oauth/service/vkontakte.php +++ /dev/null @@ -1,52 +0,0 @@ -config = $config; - } - - /** - * {@inheritdoc} - */ - public function get_service_credentials() - { - return array( - 'key' => $this->config['auth_oauth_vkontakte_key'], - 'secret' => $this->config['auth_oauth_vkontakte_secret'], - ); - } -} diff --git a/phpBB/phpbb/auth/provider/oauth/service/yammer.php b/phpBB/phpbb/auth/provider/oauth/service/yammer.php deleted file mode 100644 index fe14f13077..0000000000 --- a/phpBB/phpbb/auth/provider/oauth/service/yammer.php +++ /dev/null @@ -1,52 +0,0 @@ -config = $config; - } - - /** - * {@inheritdoc} - */ - public function get_service_credentials() - { - return array( - 'key' => $this->config['auth_oauth_yammer_key'], - 'secret' => $this->config['auth_oauth_yammer_secret'], - ); - } -} -- cgit v1.2.1 From bbbe442c425d333d7fea35b03217d0f222f1e2cc Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 18 Jul 2013 12:24:11 -0400 Subject: [feature/oauth] Finish clean up of removed providers PHPBB3-11673 --- phpBB/config/auth_providers.yml | 88 +---------------------------------------- 1 file changed, 2 insertions(+), 86 deletions(-) (limited to 'phpBB') diff --git a/phpBB/config/auth_providers.yml b/phpBB/config/auth_providers.yml index 74f674a1f9..98b51fb917 100644 --- a/phpBB/config/auth_providers.yml +++ b/phpBB/config/auth_providers.yml @@ -52,12 +52,6 @@ services: - @service_container tags: - { name: service_collection, tag: auth.provider.oauth.service } - auth.provider.oauth.service.amazon: - class: phpbb_auth_provider_oauth_service_amazon - arguments: - - @config - tags: - - { name: auth.provider.oauth.service } auth.provider.oauth.service.bitly: class: phpbb_auth_provider_oauth_service_bitly arguments: @@ -65,92 +59,14 @@ services: - @request tags: - { name: auth.provider.oauth.service } - auth.provider.oauth.service.box: - class: phpbb_auth_provider_oauth_service_box - arguments: - - @config - tags: - - { name: auth.provider.oauth.service } - auth.provider.oauth.service.dropbox: - class: phpbb_auth_provider_oauth_service_dropbox - arguments: - - @config - tags: - - { name: auth.provider.oauth.service } auth.provider.oauth.service.facebook: class: phpbb_auth_provider_oauth_service_facebook arguments: - @config tags: - { name: auth.provider.oauth.service } - auth.provider.oauth.service.fitbit: - class: phpbb_auth_provider_oauth_service_fitbit - arguments: - - @config - tags: - - { name: auth.provider.oauth.service } - auth.provider.oauth.service.foursquare: - class: phpbb_auth_provider_oauth_service_foursquare - arguments: - - @config - tags: - - { name: auth.provider.oauth.service } - auth.provider.oauth.service.github: - class: phpbb_auth_provider_oauth_service_github - arguments: - - @config - tags: - - { name: auth.provider.oauth.service } - auth.provider.oauth.service.instagram: - class: phpbb_auth_provider_oauth_service_instagram - arguments: - - @config - tags: - - { name: auth.provider.oauth.service } - auth.provider.oauth.service.linkedin: - class: phpbb_auth_provider_oauth_service_linkedin - arguments: - - @config - tags: - - { name: auth.provider.oauth.service } - auth.provider.oauth.service.microsoft: - class: phpbb_auth_provider_oauth_service_microsoft - arguments: - - @config - tags: - - { name: auth.provider.oauth.service } - auth.provider.oauth.service.paypal: - class: phpbb_auth_provider_oauth_service_paypal - arguments: - - @config - tags: - - { name: auth.provider.oauth.service } - auth.provider.oauth.service.soundclod: - class: phpbb_auth_provider_oauth_service_soundcloud - arguments: - - @config - tags: - - { name: auth.provider.oauth.service } - auth.provider.oauth.service.tumblr: - class: phpbb_auth_provider_oauth_service_tumblr - arguments: - - @config - tags: - - { name: auth.provider.oauth.service } - auth.provider.oauth.service.twitter: - class: phpbb_auth_provider_oauth_service_twitter - arguments: - - @config - tags: - - { name: auth.provider.oauth.service } - auth.provider.oauth.service.vkontakte: - class: phpbb_auth_provider_oauth_service_vkontakte - arguments: - - @config - tags: - - { name: auth.provider.oauth.service } - auth.provider.oauth.service.yammer: - class: phpbb_auth_provider_oauth_service_yammer + auth.provider.oauth.service.google: + class: phpbb_auth_provider_oauth_service_google arguments: - @config tags: -- cgit v1.2.1 From 2faaa7f63cd45244cd536b507325e65c5f085b39 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 18 Jul 2013 12:50:42 -0400 Subject: [feature/oauth] Update service files + check for existing links PHPBB3-11673 --- phpBB/config/auth_providers.yml | 3 ++- phpBB/config/tables.yml | 3 ++- phpBB/phpbb/auth/provider/oauth/oauth.php | 32 ++++++++++++++++++++++++------- 3 files changed, 29 insertions(+), 9 deletions(-) (limited to 'phpBB') diff --git a/phpBB/config/auth_providers.yml b/phpBB/config/auth_providers.yml index 98b51fb917..b7486eabf4 100644 --- a/phpBB/config/auth_providers.yml +++ b/phpBB/config/auth_providers.yml @@ -42,7 +42,8 @@ services: - @config - @request - @user - - %tables.auth_provider_oauth% + - %tables.auth_provider_oauth_token_storage% + - %tables.auth_provider_oauth_account_assoc% - @auth.provider.oauth.service_collection tags: - { name: auth.provider } diff --git a/phpBB/config/tables.yml b/phpBB/config/tables.yml index 48098ba8c2..e12720023d 100644 --- a/phpBB/config/tables.yml +++ b/phpBB/config/tables.yml @@ -1,5 +1,6 @@ parameters: - tables.auth_provider_oauth: %core.table_prefix%auth_provider_oauth + tables.auth_provider_oauth_token_storage: %core.table_prefix%auth_provider_oauth_token_storage + tables.auth_provider_oauth_account_assoc: %core.table_prefix%auth_provider_oauth_account_assoc tables.config: %core.table_prefix%config tables.config_text: %core.table_prefix%config_text tables.ext: %core.table_prefix%ext diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index fc6fce3db0..afaae8a8ea 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -58,7 +58,14 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base * * @var string */ - protected $auth_provider_oauth_table; + protected $auth_provider_oauth_token_storage_table; + + /** + * OAuth account association table + * + * @var string + */ + protected $auth_provider_oauth_token_account_assoc; /** * Cached services once they has been created @@ -88,16 +95,18 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base * @param phpbb_config $config * @param phpbb_request $request * @param phpbb_user $user - * @param string $auth_provider_oauth_table + * @param string $auth_provider_oauth_token_storage_table + * @param string $auth_provider_oauth_token_account_assoc * @param phpbb_auth_provider_oauth_service_interface $service_providers */ - public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_request $request, phpbb_user $user, $auth_provider_oauth_table, phpbb_auth_provider_oauth_service_interface $service_providers) + public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_request $request, phpbb_user $user, $auth_provider_oauth_token_storage_table, $auth_provider_oauth_token_account_assoc, phpbb_auth_provider_oauth_service_interface $service_providers) { $this->db = $db; $this->config = $config; $this->request = $request; $this->user = $user; - $this->auth_provider_oauth_table = $auth_provider_oauth_table; + $this->auth_provider_oauth_token_storage_table = $auth_provider_oauth_token_storage_table; + $this->auth_provider_oauth_token_account_assoc = $auth_provider_oauth_token_account_assoc; $this->service_providers = $service_providers; $this->services = array(); } @@ -123,15 +132,24 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base // Get the service credentials for the given service $service_credentials = $this->services[$service_name]->get_credentials(); - $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_table); + $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_token_storage_table); $service = $this->get_service($service_name, $storage, $service_credentials, $this->services[$service_name]->get_auth_scope()); if ($this->request->is_set('code', phpbb_request_interface::GET)) { $this->services[$service_name]->set_external_service_provider($service); - $result = $this->services[$service_name]->perform_auth_login(); + $unique_id = $this->services[$service_name]->perform_auth_login(); - // Perform authentication + // Check to see if this provider is already assosciated with an account + $data = array( + 'oauth_provider' => $service_name, + 'oauth_provider_id' => $unique_id + ); + $sql = 'SELECT user_id FROM' . $this->auth_provider_oauth_token_account_assoc . ' + WHERE ' . $this->db->sql_build_array('SELECT', $data); + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); } else { $url = $service->getAuthorizationUri(); // TODO: modify $url for the appropriate return points -- cgit v1.2.1 From 36f7913cc06aa299fa93ce83e4084993d31f1368 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 18 Jul 2013 15:31:13 -0400 Subject: [feature/oauth] Finish authenticating user code PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index afaae8a8ea..921ce830d9 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -150,6 +150,33 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); + + if (!$row) + { + // Account not tied to any existing account + // TODO: determine action that should occur + } + + // Retrieve the user's account + $sql = 'SELECT user_id, username, user_password, user_passchg, user_pass_convert, user_email, user_type, user_login_attempts + FROM ' . USERS_TABLE . " + WHERE user_id = '" . $this->db->sql_escape($row['user_id']) . "'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if (!$row) + { + // TODO: Update exception type and change it to language constant + throw new Exception('Invalid entry in ' . $this->auth_provider_oauth_token_account_assoc); + } + + // The user is now authenticated and can be logged in + return array( + 'status' => LOGIN_SUCCESS, + 'error_msg' => false, + 'user_row' => $row, + ); } else { $url = $service->getAuthorizationUri(); // TODO: modify $url for the appropriate return points -- cgit v1.2.1 From 2eb47d00e078cf7b0dd3a12e2557a33ca89d297a Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 18 Jul 2013 15:33:14 -0400 Subject: [feature/oauth] Remove unused method PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 51 ------------------------------- 1 file changed, 51 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 921ce830d9..2ad204c472 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -236,55 +236,4 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base return $this->service[$service_name]; } - - /** - * Returns the path desired of the service - * - * @param string $service_name - * @return string|UriInterface|null A null return means do not - * request additional information. - */ - protected function get_path($service_name) - { - switch ($service_name) - { - case 'bitly': - case 'tumblr': - $path = 'user/info'; - break; - case 'box': - $path = '/users/me'; - break; - case 'facebook': - $path = '/me'; - break; - case 'FitBit': - $path = 'user/-/profile.json'; - break; - case 'foursquare': - case 'instagram': - $path = 'users/self'; - break; - case 'GitHub': - $path = 'user/emails'; - break; - case 'google': - $path = 'https://www.googleapis.com/oauth2/v1/userinfo'; - break; - case 'linkedin': - $path = '/people/~?format=json'; - break; - case 'soundCloud': - $path = 'me.json'; - break; - case 'twitter': - $path = 'account/verify_credentials.json'; - break; - default: - $path = null; - break; - } - - return $path; - } } -- cgit v1.2.1 From 772a977afcd4919c9d8bfcc8e402f4af4d3aefbf Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 18 Jul 2013 16:03:29 -0400 Subject: [feature/oauth] Facebook support PHPBB3-11673 --- .../phpbb/auth/provider/oauth/service/facebook.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/service/facebook.php b/phpBB/phpbb/auth/provider/oauth/service/facebook.php index 87e8749b55..fcf41755b7 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/facebook.php +++ b/phpBB/phpbb/auth/provider/oauth/service/facebook.php @@ -49,4 +49,25 @@ class phpbb_auth_provider_oauth_service_facebook extends phpbb_auth_provider_oau 'secret' => $this->config['auth_oauth_facebook_secret'], ); } + + /** + * {@inheritdoc} + */ + public function perform_auth_login() + { + if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Facebook)) + { + // TODO: make exception class and use language constant + throw new Exception('Invalid service provider type'); + } + + // This was a callback request from bitly, get the token + $this->service_provider->requestAccessToken( $this->request->variable('code', '') ); + + // Send a request with it + $result = json_decode( $this->service_provider->request('/me'), true ); + + // Return the unique identifier returned from bitly + return $result['id']; + } } -- cgit v1.2.1 From a673eb8cbc8c464e550a5528f932e07a079f1fac Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 18 Jul 2013 16:04:44 -0400 Subject: [feature/oauth] Google support PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/service/google.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/service/google.php b/phpBB/phpbb/auth/provider/oauth/service/google.php index b9b1851424..70bad77697 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/google.php +++ b/phpBB/phpbb/auth/provider/oauth/service/google.php @@ -60,4 +60,25 @@ class phpbb_auth_provider_oauth_service_google extends phpbb_auth_provider_oauth 'secret' => $this->config['auth_oauth_google_secret'], ); } + + /** + * {@inheritdoc} + */ + public function perform_auth_login() + { + if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Google)) + { + // TODO: make exception class and use language constant + throw new Exception('Invalid service provider type'); + } + + // This was a callback request from bitly, get the token + $this->service_provider->requestAccessToken( $this->request->variable('code', '') ); + + // Send a request with it + $result = json_decode( $this->service_provider->request('https://www.googleapis.com/oauth2/v1/userinfo'), true ); + + // Return the unique identifier returned from bitly + return $result['id']; + } } -- cgit v1.2.1 From 0f292f70c78b5c2e7e19ba02bb484d14b2a94c9d Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 18 Jul 2013 20:05:13 -0400 Subject: [feature/oauth] Fix fatal error PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 2ad204c472..c10ac3e9da 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -77,7 +77,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base /** * All OAuth service providers * - * @var array Contains phpbb_auth_provider_oauth_service_interface + * @var phpbb_di_service_collection Contains phpbb_auth_provider_oauth_service_interface */ protected $service_providers; @@ -97,9 +97,9 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base * @param phpbb_user $user * @param string $auth_provider_oauth_token_storage_table * @param string $auth_provider_oauth_token_account_assoc - * @param phpbb_auth_provider_oauth_service_interface $service_providers + * @param phpbb_di_service_collection $service_providers Contains phpbb_auth_provider_oauth_service_interface */ - public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_request $request, phpbb_user $user, $auth_provider_oauth_token_storage_table, $auth_provider_oauth_token_account_assoc, phpbb_auth_provider_oauth_service_interface $service_providers) + public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_request $request, phpbb_user $user, $auth_provider_oauth_token_storage_table, $auth_provider_oauth_token_account_assoc, phpbb_di_service_collection $service_providers) { $this->db = $db; $this->config = $config; -- cgit v1.2.1 From b67032fb028b096b33c72fe7aabec55056243755 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 18 Jul 2013 20:49:25 -0400 Subject: [feature/oauth] Temporary workaround for only allowing one auth provider PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index c10ac3e9da..6f2fc52cfa 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -116,6 +116,15 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base */ public function login($username, $password) { + // Temporary workaround for only having one authentication provider available + if ($username && $password) + { + // TODO: Remove before merging + global $phpbb_root_path, $phpEx; + $provider = new phpbb_auth_provider_db($this->db, $this->config, $this->request, $this->user, $phpbb_root_path, $phpEx); + return $provider->login($username, $password); + } + // Requst the name of the OAuth service $service_name = $this->request->variable('oauth_service', '', false, phpbb_request_interface::POST); $service_name = strtolower($service_name); -- cgit v1.2.1 From f852485513ee4e032cf9c25acb2d72980f783c24 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 18 Jul 2013 21:02:00 -0400 Subject: [feature/oauth] Fix a bunch of errors in oauth.php PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 6f2fc52cfa..9be404dade 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -128,7 +128,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base // Requst the name of the OAuth service $service_name = $this->request->variable('oauth_service', '', false, phpbb_request_interface::POST); $service_name = strtolower($service_name); - if ($service_name === '' && isset($this->services[$service_name])) + if ($service_name === '' || !array_key_exists($service_name, $this->service_providers)) { return array( 'status' => LOGIN_ERROR_EXTERNAL_AUTH, @@ -139,15 +139,15 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base } // Get the service credentials for the given service - $service_credentials = $this->services[$service_name]->get_credentials(); + $service_credentials = $this->service_providers[$service_name]->get_credentials(); $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_token_storage_table); - $service = $this->get_service($service_name, $storage, $service_credentials, $this->services[$service_name]->get_auth_scope()); + $service = $this->get_service($service_name, $storage, $service_credentials, $this->service_providers[$service_name]->get_auth_scope()); if ($this->request->is_set('code', phpbb_request_interface::GET)) { - $this->services[$service_name]->set_external_service_provider($service); - $unique_id = $this->services[$service_name]->perform_auth_login(); + $this->service_providers[$service_name]->set_external_service_provider($service); + $unique_id = $this->service_providers[$service_name]->perform_auth_login(); // Check to see if this provider is already assosciated with an account $data = array( -- cgit v1.2.1 From 4c48da0597c148c58925cdedbd4e79fb63eaf76a Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 18 Jul 2013 21:03:57 -0400 Subject: [feature/oauth] Clean up unneeded complexity PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 9be404dade..20c82e63d7 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -67,13 +67,6 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base */ protected $auth_provider_oauth_token_account_assoc; - /** - * Cached services once they has been created - * - * @var array Contains \OAuth\Common\Service\ServiceInterface or null - */ - protected $services; - /** * All OAuth service providers * @@ -108,7 +101,6 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base $this->auth_provider_oauth_token_storage_table = $auth_provider_oauth_token_storage_table; $this->auth_provider_oauth_token_account_assoc = $auth_provider_oauth_token_account_assoc; $this->service_providers = $service_providers; - $this->services = array(); } /** @@ -226,11 +218,6 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base */ protected function get_service($service_name, phpbb_auth_oauth_token_storage $storage, array $service_credentials, array $scopes = array()) { - if ($this->services[$service_name]) - { - return $this->services[$service_name]; - } - $current_uri = $this->get_current_uri(); // Setup the credentials for the requests @@ -241,8 +228,6 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base ); $service_factory = new \OAuth\ServiceFactory(); - $this->service[$service_name] = $service_factory->createService($service_name, $credentials, $storage, $scopes); - - return $this->service[$service_name]; + return $service_factory->createService($service_name, $credentials, $storage, $scopes); } } -- cgit v1.2.1 From d804842cef945dbc7ec2c6c1d145587c62f06f65 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 22 Jul 2013 15:58:32 -0400 Subject: [feature/oauth] Fall back to DB login if OAuth is enabled but not requested PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 20c82e63d7..7f3de0f4d9 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -109,7 +109,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base public function login($username, $password) { // Temporary workaround for only having one authentication provider available - if ($username && $password) + if (!$this->request->is_set_post('oauth_service')) { // TODO: Remove before merging global $phpbb_root_path, $phpEx; -- cgit v1.2.1 From cd49cfacfb0faddce8343837b69eb919b8652352 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 22 Jul 2013 16:23:13 -0400 Subject: [feature/oauth] Initial step in creating OAuth login support PHPBB3-11673 --- phpBB/includes/functions.php | 12 +++++++++++- phpBB/phpbb/auth/provider/oauth/oauth.php | 10 ++++++++++ phpBB/styles/prosilver/template/login_body.html | 6 +++++- 3 files changed, 26 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 49f2e469bc..1bb9cc8299 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3199,7 +3199,7 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = false, $s_display = true) { global $db, $user, $template, $auth, $phpEx, $phpbb_root_path, $config; - global $request; + global $request, $phpbb_container; if (!class_exists('phpbb_captcha_factory', false)) { @@ -3367,12 +3367,22 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa $s_hidden_fields['credential'] = $credential; } + $oauth_login = ($config['auth_method'] == 'oauth') ? true : false; + + if ($oauth_login) + { + $auth_provider = $phpbb_container->get('auth.provider.oauth'); + $oauth_box_data = $auth_provider->get_login_data(); + } + $s_hidden_fields = build_hidden_fields($s_hidden_fields); $template->assign_vars(array( 'LOGIN_ERROR' => $err, 'LOGIN_EXPLAIN' => $l_explain, + 'OAUTH_LOGIN' => $oauth_login, + 'U_SEND_PASSWORD' => ($config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=sendpassword') : '', 'U_RESEND_ACTIVATION' => ($config['require_activation'] == USER_ACTIVATION_SELF && $config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=resend_act') : '', 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'), diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 7f3de0f4d9..eeb4b23be4 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -230,4 +230,14 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base $service_factory = new \OAuth\ServiceFactory(); return $service_factory->createService($service_name, $credentials, $storage, $scopes); } + + /** + * Returns an array of login data for all enabled OAuth services. + * + * @return array + */ + public function get_login_data() + { + return array(); + } } diff --git a/phpBB/styles/prosilver/template/login_body.html b/phpBB/styles/prosilver/template/login_body.html index 89ef8acd6f..4a51cf477f 100644 --- a/phpBB/styles/prosilver/template/login_body.html +++ b/phpBB/styles/prosilver/template/login_body.html @@ -46,7 +46,11 @@
{S_HIDDEN_FIELDS}
- + + +
+ hi +
-- cgit v1.2.1 From 0be81468e7f61b8c2fc1c9729ff5d217c7424026 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 22 Jul 2013 16:35:18 -0400 Subject: [feature/oauth] Possible way of getting the login data to login_box() PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 18 +++++++++++++++++- phpBB/styles/prosilver/template/login_body.html | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index eeb4b23be4..e43579a740 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -238,6 +238,22 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base */ public function get_login_data() { - return array(); + $login_data = array(); + + foreach ($this->service_providers as $service_name => $service_provider) + { + // Only include data if the credentials are set + $credentials = $service_provider->get_service_credentials(); + if ($credentials['key'] && $credentials['secret']) + { + $login_data[$service_provider] = array(); + + // Build the redirect url for the box + $redirect_url = build_url(false) . '&oauth_service=' . $service_name; + $login_data[$service_provider]['url'] = redirect($redirect_url, true); + } + } + + return $login_data; } } diff --git a/phpBB/styles/prosilver/template/login_body.html b/phpBB/styles/prosilver/template/login_body.html index 4a51cf477f..85a47be4ad 100644 --- a/phpBB/styles/prosilver/template/login_body.html +++ b/phpBB/styles/prosilver/template/login_body.html @@ -49,7 +49,7 @@
- hi +
-- cgit v1.2.1 From 5578b7a578cd9b2e8045d65c883a355f7a9f5394 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 22 Jul 2013 17:27:16 -0400 Subject: [feature/oauth] Initial UI element added, this is non-final At this point, all UI changes are purely for testing and should not be considered final. PHPBB3-11673 --- phpBB/includes/functions.php | 7 +++++++ phpBB/styles/prosilver/template/login_body.html | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 1bb9cc8299..bbe3033fb5 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3373,6 +3373,13 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa { $auth_provider = $phpbb_container->get('auth.provider.oauth'); $oauth_box_data = $auth_provider->get_login_data(); + foreach ($oauth_box_data as $service_name => $data) + { + $template->assign_block_vars('oauth', array( + 'SERVICE_NAME' => $service_name, + 'REDIRECT_URL' => $data['url'], + )); + } } $s_hidden_fields = build_hidden_fields($s_hidden_fields); diff --git a/phpBB/styles/prosilver/template/login_body.html b/phpBB/styles/prosilver/template/login_body.html index 85a47be4ad..64b3915a1b 100644 --- a/phpBB/styles/prosilver/template/login_body.html +++ b/phpBB/styles/prosilver/template/login_body.html @@ -49,7 +49,12 @@
- + +
+
 
+
{oauth.SERVICE_NAME}
+
+
-- cgit v1.2.1 From 93cbdc37b51edf14cb2dbebb1ccb71a612f7fd94 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Tue, 23 Jul 2013 14:06:01 -0400 Subject: [feature/oauth] ACP options for OAuth, needs some work PHPBB3-11673 --- phpBB/adm/style/auth_provider_oauth.html | 15 +++++++++++++++ phpBB/includes/acp/acp_board.php | 10 +++++++++- phpBB/language/en/acp/board.php | 9 +++++++++ phpBB/phpbb/auth/provider/oauth/oauth.php | 22 ++++++++++++++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 phpBB/adm/style/auth_provider_oauth.html (limited to 'phpBB') diff --git a/phpBB/adm/style/auth_provider_oauth.html b/phpBB/adm/style/auth_provider_oauth.html new file mode 100644 index 0000000000..e3e246d727 --- /dev/null +++ b/phpBB/adm/style/auth_provider_oauth.html @@ -0,0 +1,15 @@ +

{L_AUTH_PROVIDER_OAUTH_TITLE}

+ + +
+ {oauth_services.ACTUAL_NAME} +
+

{L_AUTH_PROVIDER_OAUTH_KEY_EXPLAIN}
+
+
+
+

{L_AUTH_PROVIDER_OAUTH_SECRET_EXPLAIN}
+
+
+
+ diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 12e2a1bf72..0af0fbec86 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -658,7 +658,15 @@ class acp_board $auth_tpl = $provider->get_acp_template($this->new_config); if ($auth_tpl) { - $template->assign_vars($auth_tpl['TEMPLATE_VARS']); + if (array_key_exists('BLOCK_VAR_NAME', $auth_tpl)) + { + foreach ($auth_tpl['TEMPLATE_VARS'] as $block_vars) + { + $template->assign_block_vars($auth_tpl['BLOCK_VAR_NAME'], $block_vars); + } + } else { + $template->assign_vars($auth_tpl['TEMPLATE_VARS']); + } $template->assign_block_vars('auth_tpl', array( 'TEMPLATE_FILE' => $auth_tpl['TEMPLATE_FILE'], )); diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index ce15dfefb4..892d3f61fe 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -394,6 +394,15 @@ $lang = array_merge($lang, array( 'AUTH_METHOD' => 'Select an authentication method', + 'AUTH_PROVIDER_OAUTH_KEY' => 'Key', + 'AUTH_PROVIDER_OAUTH_KEY_EXPLAIN' => '', + 'AUTH_PROVIDER_OAUTH_SERVICE_BITLY' => 'Bitly', + 'AUTH_PROVIDER_OAUTH_SERVICE_FACEBOOK' => 'Facebook', + 'AUTH_PROVIDER_OAUTH_SERVICE_GOOGLE' => 'Google', + 'AUTH_PROVIDER_OAUTH_TITLE' => 'OAuth', + 'AUTH_PROVIDER_OAUTH_SECRET' => 'Secret', + 'AUTH_PROVIDER_OAUTH_SECRET_EXPLAIN' => '', + 'APACHE_SETUP_BEFORE_USE' => 'You have to setup apache authentication before you switch phpBB to this authentication method. Keep in mind that the username you use for apache authentication has to be the same as your phpBB username. Apache authentication can only be used with mod_php (not with a CGI version) and safe_mode disabled.', 'LDAP_DN' => 'LDAP base dn', diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index e43579a740..31450a573f 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -256,4 +256,26 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base return $login_data; } + + /** + * {@inheritdoc} + */ + public function get_acp_template($new_config) + { + $ret = array( + 'BLOCK_VAR_NAME' => 'oauth_services', + 'TEMPLATE_FILE' => 'auth_provider_oauth.html', + 'TEMPLATE_VARS' => array(), + ); + + foreach ($this->service_providers as $service_name => $service_provider) + { + $actual_name = str_replace('auth.provider.oauth.service.', '', $service_name); + $ret['TEMPLATE_VARS'][$actual_name] = array(); + $ret['TEMPLATE_VARS'][$actual_name]['NAME'] = $actual_name; + $ret['TEMPLATE_VARS'][$actual_name]['ACTUAL_NAME'] = 'L_AUTH_PROVIDER_OAUTH_SERVICE_' . strtoupper($actual_name); + } + + return $ret; + } } -- cgit v1.2.1 From 32678f63ed04a8770720da4d94d01648dc595e82 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Tue, 23 Jul 2013 14:13:51 -0400 Subject: [feature/oauth] Finish the template so it "works" PHPBB3-11673 --- phpBB/adm/style/auth_provider_oauth.html | 4 ++-- phpBB/phpbb/auth/provider/oauth/oauth.php | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'phpBB') diff --git a/phpBB/adm/style/auth_provider_oauth.html b/phpBB/adm/style/auth_provider_oauth.html index e3e246d727..87f8716c5e 100644 --- a/phpBB/adm/style/auth_provider_oauth.html +++ b/phpBB/adm/style/auth_provider_oauth.html @@ -5,11 +5,11 @@ {oauth_services.ACTUAL_NAME}

{L_AUTH_PROVIDER_OAUTH_KEY_EXPLAIN}
-
+

{L_AUTH_PROVIDER_OAUTH_SECRET_EXPLAIN}
-
+
diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 31450a573f..6ad0293e8e 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -271,9 +271,12 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base foreach ($this->service_providers as $service_name => $service_provider) { $actual_name = str_replace('auth.provider.oauth.service.', '', $service_name); - $ret['TEMPLATE_VARS'][$actual_name] = array(); - $ret['TEMPLATE_VARS'][$actual_name]['NAME'] = $actual_name; - $ret['TEMPLATE_VARS'][$actual_name]['ACTUAL_NAME'] = 'L_AUTH_PROVIDER_OAUTH_SERVICE_' . strtoupper($actual_name); + $ret['TEMPLATE_VARS'][$actual_name] = array( + 'ACTUAL_NAME' => 'L_AUTH_PROVIDER_OAUTH_SERVICE_' . strtoupper($actual_name), + 'KEY' => $new_config['auth_oauth_' . $actual_name . '_key'], + 'NAME' => $actual_name, + 'SECRET' => $new_config['auth_oauth_' . $actual_name . '_secret'], + ); } return $ret; -- cgit v1.2.1 From 2fc4be1a31e44f30ea96914bf657e4e7b2236760 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Tue, 23 Jul 2013 14:24:31 -0400 Subject: [feature/oauth] Fix language bug with new ACP OAuth template PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 6ad0293e8e..a94e6041d9 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -272,7 +272,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base { $actual_name = str_replace('auth.provider.oauth.service.', '', $service_name); $ret['TEMPLATE_VARS'][$actual_name] = array( - 'ACTUAL_NAME' => 'L_AUTH_PROVIDER_OAUTH_SERVICE_' . strtoupper($actual_name), + 'ACTUAL_NAME' => $this->user->lang['AUTH_PROVIDER_OAUTH_SERVICE_' . strtoupper($actual_name)], 'KEY' => $new_config['auth_oauth_' . $actual_name . '_key'], 'NAME' => $actual_name, 'SECRET' => $new_config['auth_oauth_' . $actual_name . '_secret'], -- cgit v1.2.1 From af6a4b21614c602ae8fe5323fab2b384c6ad5393 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Tue, 23 Jul 2013 14:29:38 -0400 Subject: [feature/oauth] Clean up the OAuth ACP template PHPBB3-11673 --- phpBB/adm/style/auth_provider_oauth.html | 6 ++++-- phpBB/language/en/acp/board.php | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'phpBB') diff --git a/phpBB/adm/style/auth_provider_oauth.html b/phpBB/adm/style/auth_provider_oauth.html index 87f8716c5e..25e40ff596 100644 --- a/phpBB/adm/style/auth_provider_oauth.html +++ b/phpBB/adm/style/auth_provider_oauth.html @@ -1,14 +1,16 @@

{L_AUTH_PROVIDER_OAUTH_TITLE}

+

{L_AUTH_PROVIDER_OAUTH_EXPLAIN}

+
{oauth_services.ACTUAL_NAME}
-

{L_AUTH_PROVIDER_OAUTH_KEY_EXPLAIN}
+
-

{L_AUTH_PROVIDER_OAUTH_SECRET_EXPLAIN}
+
diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index 892d3f61fe..553cd1a6eb 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -394,14 +394,13 @@ $lang = array_merge($lang, array( 'AUTH_METHOD' => 'Select an authentication method', + 'AUTH_PROVIDER_OAUTH_EXPLAIN' => 'Each OAuth provider requires a unique secret and key in order to authenticate with the external server.
These should be supplied by the OAuth service when you register your website with them and should be entered exactly as provided to you.
Any service that does not have both a key and a secret entered here will not be available for use by the forum users.', 'AUTH_PROVIDER_OAUTH_KEY' => 'Key', - 'AUTH_PROVIDER_OAUTH_KEY_EXPLAIN' => '', 'AUTH_PROVIDER_OAUTH_SERVICE_BITLY' => 'Bitly', 'AUTH_PROVIDER_OAUTH_SERVICE_FACEBOOK' => 'Facebook', 'AUTH_PROVIDER_OAUTH_SERVICE_GOOGLE' => 'Google', 'AUTH_PROVIDER_OAUTH_TITLE' => 'OAuth', 'AUTH_PROVIDER_OAUTH_SECRET' => 'Secret', - 'AUTH_PROVIDER_OAUTH_SECRET_EXPLAIN' => '', 'APACHE_SETUP_BEFORE_USE' => 'You have to setup apache authentication before you switch phpBB to this authentication method. Keep in mind that the username you use for apache authentication has to be the same as your phpBB username. Apache authentication can only be used with mod_php (not with a CGI version) and safe_mode disabled.', -- cgit v1.2.1 From 0857d14030177271bd346f188ced38e9d6da47ff Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Tue, 23 Jul 2013 14:41:21 -0400 Subject: [feature/oauth] Update auth provider interface docs for block vars in ACP PHPBB3-11673 --- phpBB/includes/acp/acp_board.php | 5 ++--- phpBB/phpbb/auth/provider/interface.php | 18 ++++++++++++++++++ phpBB/phpbb/auth/provider/oauth/oauth.php | 3 ++- 3 files changed, 22 insertions(+), 4 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 0af0fbec86..51a7628b68 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -660,13 +660,12 @@ class acp_board { if (array_key_exists('BLOCK_VAR_NAME', $auth_tpl)) { - foreach ($auth_tpl['TEMPLATE_VARS'] as $block_vars) + foreach ($auth_tpl['BLOCK_VARS'] as $block_vars) { $template->assign_block_vars($auth_tpl['BLOCK_VAR_NAME'], $block_vars); } - } else { - $template->assign_vars($auth_tpl['TEMPLATE_VARS']); } + $template->assign_vars($auth_tpl['TEMPLATE_VARS']); $template->assign_block_vars('auth_tpl', array( 'TEMPLATE_FILE' => $auth_tpl['TEMPLATE_FILE'], )); diff --git a/phpBB/phpbb/auth/provider/interface.php b/phpBB/phpbb/auth/provider/interface.php index 47043bc107..f4344c1dc7 100644 --- a/phpBB/phpbb/auth/provider/interface.php +++ b/phpBB/phpbb/auth/provider/interface.php @@ -80,6 +80,24 @@ interface phpbb_auth_provider_interface * 'TEMPLATE_FILE' => string, * 'TEMPLATE_VARS' => array(...), * ) + * An optional third element may be added to this + * array: 'BLOCK_VAR_NAME'. If this is present, + * then it's value should be a string that is used + * to designate the name of the loop used in the + * ACP template file. In addition to this, an + * additional key named 'BLOCK_VARS' is required. + * This must be an array containing at least one + * array of variables that will be assigned during + * the loop in the template. An example of this is + * presented below: + * array( + * 'BLOCK_VAR_NAME' => string, + * 'BLOCK_VARS' => array( + * 'KEY IS UNIMPORTANT' => array(...), + * ), + * 'TEMPLATE_FILE' => string, + * 'TEMPLATE_VARS' => array(...), + * ) */ public function get_acp_template($new_config); diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index a94e6041d9..133d9f11ef 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -264,6 +264,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base { $ret = array( 'BLOCK_VAR_NAME' => 'oauth_services', + 'BLOCK_VARS' => array(), 'TEMPLATE_FILE' => 'auth_provider_oauth.html', 'TEMPLATE_VARS' => array(), ); @@ -271,7 +272,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base foreach ($this->service_providers as $service_name => $service_provider) { $actual_name = str_replace('auth.provider.oauth.service.', '', $service_name); - $ret['TEMPLATE_VARS'][$actual_name] = array( + $ret['BLOCK_VARS'][$actual_name] = array( 'ACTUAL_NAME' => $this->user->lang['AUTH_PROVIDER_OAUTH_SERVICE_' . strtoupper($actual_name)], 'KEY' => $new_config['auth_oauth_' . $actual_name . '_key'], 'NAME' => $actual_name, -- cgit v1.2.1 From 77c32645437c77e99f36f6595e1a42cd0f7b7235 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Tue, 23 Jul 2013 14:52:32 -0400 Subject: [feature/oauth] OAuth acp() method to return config field names PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 133d9f11ef..978c84cd6d 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -257,6 +257,23 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base return $login_data; } + /** + * {@inheritdoc} + */ + public function acp() + { + $ret = array(); + + foreach ($this->service_providers as $service_name => $service_provider) + { + $actual_name = str_replace('auth.provider.oauth.service.', '', $service_name); + $ret[] = 'auth_oauth_' . $actual_name . '_key'; + $ret[] = 'auth_oauth_' . $actual_name . '_secret'; + } + + return $ret; + } + /** * {@inheritdoc} */ -- cgit v1.2.1 From 9805927fac30d9c5d99f5f5f8d7207c9a6064724 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Tue, 23 Jul 2013 15:26:33 -0400 Subject: [feature/oauth] OAuth init method to minimally validate entered data PHPBB3-11673 --- phpBB/language/en/acp/board.php | 15 ++++++++------- phpBB/phpbb/auth/provider/oauth/oauth.php | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+), 7 deletions(-) (limited to 'phpBB') diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index 553cd1a6eb..f76834ae50 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -394,13 +394,14 @@ $lang = array_merge($lang, array( 'AUTH_METHOD' => 'Select an authentication method', - 'AUTH_PROVIDER_OAUTH_EXPLAIN' => 'Each OAuth provider requires a unique secret and key in order to authenticate with the external server.
These should be supplied by the OAuth service when you register your website with them and should be entered exactly as provided to you.
Any service that does not have both a key and a secret entered here will not be available for use by the forum users.', - 'AUTH_PROVIDER_OAUTH_KEY' => 'Key', - 'AUTH_PROVIDER_OAUTH_SERVICE_BITLY' => 'Bitly', - 'AUTH_PROVIDER_OAUTH_SERVICE_FACEBOOK' => 'Facebook', - 'AUTH_PROVIDER_OAUTH_SERVICE_GOOGLE' => 'Google', - 'AUTH_PROVIDER_OAUTH_TITLE' => 'OAuth', - 'AUTH_PROVIDER_OAUTH_SECRET' => 'Secret', + 'AUTH_PROVIDER_OAUTH_ERROR_ELEMENT_MISSING' => 'Both the key and secret of each enabled OAuth service provider must be provided. Only one was provided for an OAuth service provider.', + 'AUTH_PROVIDER_OAUTH_EXPLAIN' => 'Each OAuth provider requires a unique secret and key in order to authenticate with the external server.
These should be supplied by the OAuth service when you register your website with them and should be entered exactly as provided to you.
Any service that does not have both a key and a secret entered here will not be available for use by the forum users.', + 'AUTH_PROVIDER_OAUTH_KEY' => 'Key', + 'AUTH_PROVIDER_OAUTH_SERVICE_BITLY' => 'Bitly', + 'AUTH_PROVIDER_OAUTH_SERVICE_FACEBOOK' => 'Facebook', + 'AUTH_PROVIDER_OAUTH_SERVICE_GOOGLE' => 'Google', + 'AUTH_PROVIDER_OAUTH_TITLE' => 'OAuth', + 'AUTH_PROVIDER_OAUTH_SECRET' => 'Secret', 'APACHE_SETUP_BEFORE_USE' => 'You have to setup apache authentication before you switch phpBB to this authentication method. Keep in mind that the username you use for apache authentication has to be the same as your phpBB username. Apache authentication can only be used with mod_php (not with a CGI version) and safe_mode disabled.', diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 978c84cd6d..a2d5c3fcd5 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -103,6 +103,24 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base $this->service_providers = $service_providers; } + /** + * {@inheritdoc} + */ + public function init() + { + // This does not test whether or not the key and secret provided are valid. + foreach ($this->service_providers as $service_provider) + { + $credentials = $service_provider->get_service_credentials(); + + if (($credentials['key'] && !$credentials['secret']) || (!$credentials['key'] && $credentials['secret'])) + { + return $this->user->lang['AUTH_PROVIDER_OAUTH_ERROR_ELEMENT_MISSING']; + } + } + return false; + } + /** * {@inheritdoc} */ -- cgit v1.2.1 From c26b68cc54b19d91affae6f4dbab67a33939ca23 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Tue, 23 Jul 2013 19:27:55 -0400 Subject: [feature/oauth] Update error message with actual error PHPBB3-11673 --- phpBB/language/en/common.php | 1 + phpBB/phpbb/auth/provider/oauth/oauth.php | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index b188d90f3a..a68c027554 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -351,6 +351,7 @@ $lang = array_merge($lang, array( 'LOGIN_CONFIRM_EXPLAIN' => 'To prevent brute forcing accounts the board requires you to enter a confirmation code after a maximum amount of failed logins. The code is displayed in the image you should see below. If you are visually impaired or cannot otherwise read this code please contact the %sBoard Administrator%s.', // unused 'LOGIN_ERROR_ATTEMPTS' => 'You exceeded the maximum allowed number of login attempts. In addition to your username and password you now also have to solve the CAPTCHA below.', 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE' => 'You have not been authenticated by Apache.', + 'LOGIN_ERROR_OAUTH_SERVICE_DOES_NOT_EXIST' => 'A non-existant OAuth service has been requested.', 'LOGIN_ERROR_PASSWORD' => 'You have specified an incorrect password. Please check your password and try again. If you continue to have problems please contact the %sBoard Administrator%s.', 'LOGIN_ERROR_PASSWORD_CONVERT' => 'It was not possible to convert your password when updating this bulletin board’s software. Please %srequest a new password%s. If you continue to have problems please contact the %sBoard Administrator%s.', 'LOGIN_ERROR_USERNAME' => 'You have specified an incorrect username. Please check your username and try again. If you continue to have problems please contact the %sBoard Administrator%s.', diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index a2d5c3fcd5..c01b23c70e 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -142,8 +142,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base { return array( 'status' => LOGIN_ERROR_EXTERNAL_AUTH, - // TODO: change error message - 'error_msg' => 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE', + 'error_msg' => 'LOGIN_ERROR_OAUTH_SERVICE_DOES_NOT_EXIST', 'user_row' => array('user_id' => ANONYMOUS), ); } -- cgit v1.2.1 From b1938576f15a43c8bf2967ab38f4484a07cc0344 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Tue, 23 Jul 2013 21:04:29 -0400 Subject: [feature/oauth] Fix outstanding issues with OAuth Includes a temporary change that allows me to test against google. This will be removed shortly. PHPBB3-11673 --- phpBB/includes/functions.php | 2 +- phpBB/phpbb/auth/provider/oauth/oauth.php | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index bbe3033fb5..b14f03f5a0 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3226,7 +3226,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa trigger_error('NO_AUTH_ADMIN'); } - if (isset($_POST['login'])) + if ($request->is_set_post('login') || ($request->is_set('login') && $request->variable('login', '') == 'external')) { // Get credential if ($admin) diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index c01b23c70e..3ffdcd4b00 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -127,7 +127,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base public function login($username, $password) { // Temporary workaround for only having one authentication provider available - if (!$this->request->is_set_post('oauth_service')) + if (!$this->request->is_set('oauth_service')) { // TODO: Remove before merging global $phpbb_root_path, $phpEx; @@ -136,9 +136,9 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base } // Requst the name of the OAuth service - $service_name = $this->request->variable('oauth_service', '', false, phpbb_request_interface::POST); - $service_name = strtolower($service_name); - if ($service_name === '' || !array_key_exists($service_name, $this->service_providers)) + $service_name_original = $this->request->variable('oauth_service', '', false); + $service_name = 'auth.provider.oauth.service.' . strtolower($service_name_original); + if ($service_name_original === '' || !array_key_exists($service_name, $this->service_providers)) { return array( 'status' => LOGIN_ERROR_EXTERNAL_AUTH, @@ -148,10 +148,10 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base } // Get the service credentials for the given service - $service_credentials = $this->service_providers[$service_name]->get_credentials(); + $service_credentials = $this->service_providers[$service_name]->get_service_credentials(); $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_token_storage_table); - $service = $this->get_service($service_name, $storage, $service_credentials, $this->service_providers[$service_name]->get_auth_scope()); + $service = $this->get_service($service_name_original, $storage, $service_credentials, $this->service_providers[$service_name]->get_auth_scope()); if ($this->request->is_set('code', phpbb_request_interface::GET)) { @@ -217,7 +217,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base $uri_factory = new \OAuth\Common\Http\Uri\UriFactory(); $current_uri = $uri_factory->createFromSuperGlobalArray($this->request->get_super_global(phpbb_request_interface::SERVER)); - $current_uri->setQuery(''); + $current_uri->setQuery('?mode=login&login=external&oauth_service=google'); $this->current_uri = $current_uri; return $current_uri; @@ -233,7 +233,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base * the api. * @return \OAuth\Common\Service\ServiceInterface */ - protected function get_service($service_name, phpbb_auth_oauth_token_storage $storage, array $service_credentials, array $scopes = array()) + protected function get_service($service_name, phpbb_auth_provider_oauth_token_storage $storage, array $service_credentials, array $scopes = array()) { $current_uri = $this->get_current_uri(); @@ -245,7 +245,15 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base ); $service_factory = new \OAuth\ServiceFactory(); - return $service_factory->createService($service_name, $credentials, $storage, $scopes); + $service = $service_factory->createService($service_name, $credentials, $storage, $scopes); + + if (!$service) + { + // Update to an actual error message + throw new Exception('Service not created: ' . $service_name); + } + + return $service; } /** -- cgit v1.2.1 From c166801fe3f7a76484eee870aac19294d192c84c Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Tue, 23 Jul 2013 21:07:04 -0400 Subject: [feature/oauth] Remove temporary google testing code PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 3ffdcd4b00..c6f7dc223e 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -206,9 +206,10 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base * Returns the cached current_uri object or creates and caches it if it is * not already created * + * @param string $service_name The name of the service * @return \OAuth\Common\Http\Uri\UriInterface */ - protected function get_current_uri() + protected function get_current_uri($service_name) { if ($this->current_uri) { @@ -217,7 +218,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base $uri_factory = new \OAuth\Common\Http\Uri\UriFactory(); $current_uri = $uri_factory->createFromSuperGlobalArray($this->request->get_super_global(phpbb_request_interface::SERVER)); - $current_uri->setQuery('?mode=login&login=external&oauth_service=google'); + $current_uri->setQuery('mode=login&login=external&oauth_service=' . $service_name); $this->current_uri = $current_uri; return $current_uri; @@ -235,7 +236,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base */ protected function get_service($service_name, phpbb_auth_provider_oauth_token_storage $storage, array $service_credentials, array $scopes = array()) { - $current_uri = $this->get_current_uri(); + $current_uri = $this->get_current_uri($service_name); // Setup the credentials for the requests $credentials = new Credentials( -- cgit v1.2.1 From fe9c97cfb45be2943eebb8ed5cbab51150e828ee Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Tue, 23 Jul 2013 21:16:19 -0400 Subject: [feature/oauth] Fix errors in OAuth PHPBB3-11673 --- phpBB/config/auth_providers.yml | 2 ++ phpBB/phpbb/auth/provider/oauth/service/base.php | 2 +- phpBB/phpbb/auth/provider/oauth/service/facebook.php | 11 ++++++++++- phpBB/phpbb/auth/provider/oauth/service/google.php | 11 ++++++++++- 4 files changed, 23 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/config/auth_providers.yml b/phpBB/config/auth_providers.yml index b7486eabf4..393c2a4229 100644 --- a/phpBB/config/auth_providers.yml +++ b/phpBB/config/auth_providers.yml @@ -64,11 +64,13 @@ services: class: phpbb_auth_provider_oauth_service_facebook arguments: - @config + - @request tags: - { name: auth.provider.oauth.service } auth.provider.oauth.service.google: class: phpbb_auth_provider_oauth_service_google arguments: - @config + - @request tags: - { name: auth.provider.oauth.service } diff --git a/phpBB/phpbb/auth/provider/oauth/service/base.php b/phpBB/phpbb/auth/provider/oauth/service/base.php index d59199f987..ccfe57c8e2 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/base.php +++ b/phpBB/phpbb/auth/provider/oauth/service/base.php @@ -50,6 +50,6 @@ abstract class phpbb_auth_provider_oauth_service_base implements phpbb_auth_prov */ public function set_external_service_provider(\OAuth\Common\Service\ServiceInterface $service_provider) { - $this->service_provider = $service; + $this->service_provider = $service_provider; } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/facebook.php b/phpBB/phpbb/auth/provider/oauth/service/facebook.php index fcf41755b7..4758ae11f8 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/facebook.php +++ b/phpBB/phpbb/auth/provider/oauth/service/facebook.php @@ -29,14 +29,23 @@ class phpbb_auth_provider_oauth_service_facebook extends phpbb_auth_provider_oau */ protected $config; + /** + * phpBB request + * + * @var phpbb_request + */ + protected $request; + /** * Constructor * * @param phpbb_config $config + * @param phpbb_request $request */ - public function __construct(phpbb_config $config) + public function __construct(phpbb_config $config, phpbb_request $request) { $this->config = $config; + $this->request = $request; } /** diff --git a/phpBB/phpbb/auth/provider/oauth/service/google.php b/phpBB/phpbb/auth/provider/oauth/service/google.php index 70bad77697..3e5735b97c 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/google.php +++ b/phpBB/phpbb/auth/provider/oauth/service/google.php @@ -29,14 +29,23 @@ class phpbb_auth_provider_oauth_service_google extends phpbb_auth_provider_oauth */ protected $config; + /** + * phpBB request + * + * @var phpbb_request + */ + protected $request; + /** * Constructor * * @param phpbb_config $config + * @param phpbb_request $request */ - public function __construct(phpbb_config $config) + public function __construct(phpbb_config $config, phpbb_request $request) { $this->config = $config; + $this->request = $request; } /** -- cgit v1.2.1 From 8d568dae7116ac05eda593835d99e6e6f22dc9f7 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Tue, 23 Jul 2013 21:22:52 -0400 Subject: [feature/oauth] Fix SQL error in token storage PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/token_storage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/token_storage.php b/phpBB/phpbb/auth/provider/oauth/token_storage.php index 227b51efc9..385fa58f25 100644 --- a/phpBB/phpbb/auth/provider/oauth/token_storage.php +++ b/phpBB/phpbb/auth/provider/oauth/token_storage.php @@ -141,7 +141,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface } $sql = 'INSERT INTO ' . $this->auth_provider_oauth_table . ' - WHERE ' . $this->db->sql_build_array('INSERT', $data); + ' . $this->db->sql_build_array('INSERT', $data); $this->db->sql_query($sql); } -- cgit v1.2.1 From e60f4bc88b32465b1d31049f2eb14b1793747dc6 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Tue, 23 Jul 2013 22:15:53 -0400 Subject: [feature/oauth] Finalize schema changes PHPBB3-11673 --- phpBB/config/tables.yml | 4 +-- phpBB/develop/create_schema_files.php | 12 +++---- phpBB/install/schemas/firebird_schema.sql | 21 ++++++++++++ phpBB/install/schemas/mssql_schema.sql | 37 ++++++++++++++++++++++ phpBB/install/schemas/mysql_40_schema.sql | 20 ++++++++++++ phpBB/install/schemas/mysql_41_schema.sql | 20 ++++++++++++ phpBB/install/schemas/oracle_schema.sql | 28 ++++++++++++++++ phpBB/install/schemas/postgres_schema.sql | 24 ++++++++++++++ phpBB/install/schemas/sqlite_schema.sql | 20 ++++++++++++ .../db/migration/data/310/auth_provider_oauth.php | 4 +-- 10 files changed, 180 insertions(+), 10 deletions(-) (limited to 'phpBB') diff --git a/phpBB/config/tables.yml b/phpBB/config/tables.yml index e12720023d..a4c730e3bf 100644 --- a/phpBB/config/tables.yml +++ b/phpBB/config/tables.yml @@ -1,6 +1,6 @@ parameters: - tables.auth_provider_oauth_token_storage: %core.table_prefix%auth_provider_oauth_token_storage - tables.auth_provider_oauth_account_assoc: %core.table_prefix%auth_provider_oauth_account_assoc + tables.auth_provider_oauth_token_storage: %core.table_prefix%oauth_token + tables.auth_provider_oauth_account_assoc: %core.table_prefix%oauth_accounts tables.config: %core.table_prefix%config tables.config_text: %core.table_prefix%config_text tables.ext: %core.table_prefix%ext diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 2cfe336511..af6e959b98 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -923,28 +923,28 @@ function get_schema_struct() ), ); - $schemda_data['auth_provider_oauth_token_storage'] = array( + $schema_data['phpbb_oauth_tokens'] = array( 'COLUMNS' => array( 'user_id' => array('UINT', 0), // phpbb_users.user_id 'session_id' => array('CHAR:32', ''), // phpbb_sessions.session_id used only when user_id not set - 'oauth_provider' => array('VCHAR'), // Name of the OAuth provider + 'provider' => array('VCHAR'), // Name of the OAuth provider 'oauth_token' => array('TEXT_UNI'), // Serialized token ), 'KEYS' => array( 'user_id' => array('INDEX', 'user_id'), - 'oauth_provider' => array('INDEX', 'oauth_provider'), + 'provider' => array('INDEX', 'oauth_provider'), ), ); - $schemda_data['auth_provider_oauth_account_assoc'] = array( + $schema_data['phpbb_oauth_accounts'] = array( 'COLUMNS' => array( 'user_id' => array('UINT', 0), - 'oauth_provider' => array('VCHAR'), + 'provider' => array('VCHAR'), 'oauth_provider_id' => array('TEXT_UNI'), ), 'PRIMARY_KEY' => array( 'user_id', - 'oauth_provider', + 'provider', ), ); diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index ca68ea387d..1eabd2f049 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -128,6 +128,27 @@ CREATE INDEX phpbb_acl_users_user_id ON phpbb_acl_users(user_id);; CREATE INDEX phpbb_acl_users_auth_option_id ON phpbb_acl_users(auth_option_id);; CREATE INDEX phpbb_acl_users_auth_role_id ON phpbb_acl_users(auth_role_id);; +# Table: 'phpbb_oauth_tokens' +CREATE TABLE phpbb_oauth_tokens ( + user_id INTEGER DEFAULT 0 NOT NULL, + session_id CHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, + provider VARCHAR(255) CHARACTER SET NONE NOT NULL, + oauth_token BLOB SUB_TYPE TEXT CHARACTER SET UTF8 NOT NULL +);; + +CREATE INDEX phpbb_oauth_tokens_user_id ON phpbb_oauth_tokens(user_id);; +CREATE INDEX phpbb_oauth_tokens_provider ON phpbb_oauth_tokens(oauth_provider);; + +# Table: 'phpbb_oauth_accounts' +CREATE TABLE phpbb_oauth_accounts ( + user_id INTEGER DEFAULT 0 NOT NULL, + provider VARCHAR(255) CHARACTER SET NONE NOT NULL, + oauth_provider_id BLOB SUB_TYPE TEXT CHARACTER SET UTF8 NOT NULL +);; + +ALTER TABLE phpbb_oauth_accounts ADD PRIMARY KEY (user_id, provider);; + + # Table: 'phpbb_banlist' CREATE TABLE phpbb_banlist ( ban_id INTEGER NOT NULL, diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index a2a6d2192c..36e3910bc8 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -166,6 +166,43 @@ CREATE INDEX [auth_role_id] ON [phpbb_acl_users]([auth_role_id]) ON [PRIMARY] GO +/* + Table: 'phpbb_oauth_tokens' +*/ +CREATE TABLE [phpbb_oauth_tokens] ( + [user_id] [int] DEFAULT (0) NOT NULL , + [session_id] [char] (32) DEFAULT ('') NOT NULL , + [provider] [varchar] (255) NOT NULL , + [oauth_token] [varchar] (4000) NOT NULL +) ON [PRIMARY] +GO + +CREATE INDEX [user_id] ON [phpbb_oauth_tokens]([user_id]) ON [PRIMARY] +GO + +CREATE INDEX [provider] ON [phpbb_oauth_tokens]([oauth_provider]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_oauth_accounts' +*/ +CREATE TABLE [phpbb_oauth_accounts] ( + [user_id] [int] DEFAULT (0) NOT NULL , + [provider] [varchar] (255) NOT NULL , + [oauth_provider_id] [varchar] (4000) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_oauth_accounts] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_oauth_accounts] PRIMARY KEY CLUSTERED + ( + [user_id], + [provider] + ) ON [PRIMARY] +GO + + /* Table: 'phpbb_banlist' */ diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 2c5931bae4..ea9c6419db 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -90,6 +90,26 @@ CREATE TABLE phpbb_acl_users ( ); +# Table: 'phpbb_oauth_tokens' +CREATE TABLE phpbb_oauth_tokens ( + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + session_id binary(32) DEFAULT '' NOT NULL, + provider varbinary(255) NOT NULL, + oauth_token blob NOT NULL, + KEY user_id (user_id), + KEY provider (oauth_provider) +); + + +# Table: 'phpbb_oauth_accounts' +CREATE TABLE phpbb_oauth_accounts ( + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + provider varbinary(255) NOT NULL, + oauth_provider_id blob NOT NULL, + PRIMARY KEY (user_id, provider) +); + + # Table: 'phpbb_banlist' CREATE TABLE phpbb_banlist ( ban_id mediumint(8) UNSIGNED NOT NULL auto_increment, diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index 7b7be3c462..0d81f03d17 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -90,6 +90,26 @@ CREATE TABLE phpbb_acl_users ( ) CHARACTER SET `utf8` COLLATE `utf8_bin`; +# Table: 'phpbb_oauth_tokens' +CREATE TABLE phpbb_oauth_tokens ( + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + session_id char(32) DEFAULT '' NOT NULL, + provider varchar(255) NOT NULL, + oauth_token text NOT NULL, + KEY user_id (user_id), + KEY provider (oauth_provider) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_oauth_accounts' +CREATE TABLE phpbb_oauth_accounts ( + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + provider varchar(255) NOT NULL, + oauth_provider_id text NOT NULL, + PRIMARY KEY (user_id, provider) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + # Table: 'phpbb_banlist' CREATE TABLE phpbb_banlist ( ban_id mediumint(8) UNSIGNED NOT NULL auto_increment, diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 75c01446d8..0868972d2d 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -210,6 +210,34 @@ CREATE INDEX phpbb_acl_users_auth_option_id ON phpbb_acl_users (auth_option_id) CREATE INDEX phpbb_acl_users_auth_role_id ON phpbb_acl_users (auth_role_id) / +/* + Table: 'phpbb_oauth_tokens' +*/ +CREATE TABLE phpbb_oauth_tokens ( + user_id number(8) DEFAULT '0' NOT NULL, + session_id char(32) DEFAULT '' , + provider varchar2(255) NOT NULL, + oauth_token clob NOT NULL +) +/ + +CREATE INDEX phpbb_oauth_tokens_user_id ON phpbb_oauth_tokens (user_id) +/ +CREATE INDEX phpbb_oauth_tokens_provider ON phpbb_oauth_tokens (oauth_provider) +/ + +/* + Table: 'phpbb_oauth_accounts' +*/ +CREATE TABLE phpbb_oauth_accounts ( + user_id number(8) DEFAULT '0' NOT NULL, + provider varchar2(255) NOT NULL, + oauth_provider_id clob NOT NULL, + CONSTRAINT pk_phpbb_oauth_accounts PRIMARY KEY (user_id, provider) +) +/ + + /* Table: 'phpbb_banlist' */ diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index c7fbe9a507..4b8f8f61e1 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -188,6 +188,30 @@ CREATE INDEX phpbb_acl_users_user_id ON phpbb_acl_users (user_id); CREATE INDEX phpbb_acl_users_auth_option_id ON phpbb_acl_users (auth_option_id); CREATE INDEX phpbb_acl_users_auth_role_id ON phpbb_acl_users (auth_role_id); +/* + Table: 'phpbb_oauth_tokens' +*/ +CREATE TABLE phpbb_oauth_tokens ( + user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + session_id char(32) DEFAULT '' NOT NULL, + provider varchar(255) NOT NULL, + oauth_token varchar(4000) NOT NULL +); + +CREATE INDEX phpbb_oauth_tokens_user_id ON phpbb_oauth_tokens (user_id); +CREATE INDEX phpbb_oauth_tokens_provider ON phpbb_oauth_tokens (oauth_provider); + +/* + Table: 'phpbb_oauth_accounts' +*/ +CREATE TABLE phpbb_oauth_accounts ( + user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + provider varchar(255) NOT NULL, + oauth_provider_id varchar(4000) NOT NULL, + PRIMARY KEY (user_id, provider) +); + + /* Table: 'phpbb_banlist' */ diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 72b2b276da..3e429850b4 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -89,6 +89,26 @@ CREATE INDEX phpbb_acl_users_user_id ON phpbb_acl_users (user_id); CREATE INDEX phpbb_acl_users_auth_option_id ON phpbb_acl_users (auth_option_id); CREATE INDEX phpbb_acl_users_auth_role_id ON phpbb_acl_users (auth_role_id); +# Table: 'phpbb_oauth_tokens' +CREATE TABLE phpbb_oauth_tokens ( + user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + session_id char(32) NOT NULL DEFAULT '', + provider varchar(255) NOT NULL , + oauth_token text(65535) NOT NULL +); + +CREATE INDEX phpbb_oauth_tokens_user_id ON phpbb_oauth_tokens (user_id); +CREATE INDEX phpbb_oauth_tokens_provider ON phpbb_oauth_tokens (oauth_provider); + +# Table: 'phpbb_oauth_accounts' +CREATE TABLE phpbb_oauth_accounts ( + user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + provider varchar(255) NOT NULL , + oauth_provider_id text(65535) NOT NULL , + PRIMARY KEY (user_id, provider) +); + + # Table: 'phpbb_banlist' CREATE TABLE phpbb_banlist ( ban_id INTEGER PRIMARY KEY NOT NULL , diff --git a/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php b/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php index 86e446e48e..5a7f9b5c8d 100644 --- a/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php +++ b/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php @@ -18,7 +18,7 @@ class phpbb_db_migration_data_310_auth_provider_oauth extends phpbb_db_migration { return array( 'add_tables' => array( - $this->table_prefix . 'auth_provider_oauth_token_storage' => array( + $this->table_prefix . 'oauth_token' => array( 'COLUMNS' => array( 'user_id' => array('UINT', 0), // phpbb_users.user_id 'session_id' => array('CHAR:32', ''), // phpbb_sessions.session_id used only when user_id not set @@ -30,7 +30,7 @@ class phpbb_db_migration_data_310_auth_provider_oauth extends phpbb_db_migration 'oauth_provider' => array('INDEX', 'oauth_provider'), ), ), - $this->table_prefix . 'auth_provider_oauth_account_assoc' => array( + $this->table_prefix . 'oauth_accounts' => array( 'COLUMNS' => array( 'user_id' => array('UINT', 0), 'oauth_provider' => array('VCHAR'), -- cgit v1.2.1 From 2483efe9a34df48a82bcceff5f966881fea2a37e Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Tue, 23 Jul 2013 22:18:41 -0400 Subject: [feature/oauth] Actual final schema changes PHPBB3-11673 --- phpBB/develop/create_schema_files.php | 10 +++++----- phpBB/install/schemas/firebird_schema.sql | 8 ++++---- phpBB/install/schemas/mssql_schema.sql | 8 ++++---- phpBB/install/schemas/mysql_40_schema.sql | 4 ++-- phpBB/install/schemas/mysql_41_schema.sql | 4 ++-- phpBB/install/schemas/oracle_schema.sql | 8 ++++---- phpBB/install/schemas/postgres_schema.sql | 8 ++++---- phpBB/install/schemas/sqlite_schema.sql | 8 ++++---- phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php | 10 +++++----- 9 files changed, 34 insertions(+), 34 deletions(-) (limited to 'phpBB') diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index af6e959b98..6f88b28140 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -927,20 +927,20 @@ function get_schema_struct() 'COLUMNS' => array( 'user_id' => array('UINT', 0), // phpbb_users.user_id 'session_id' => array('CHAR:32', ''), // phpbb_sessions.session_id used only when user_id not set - 'provider' => array('VCHAR'), // Name of the OAuth provider - 'oauth_token' => array('TEXT_UNI'), // Serialized token + 'provider' => array('VCHAR', ''), // Name of the OAuth provider + 'oauth_token' => array('TEXT_UNI', ''), // Serialized token ), 'KEYS' => array( 'user_id' => array('INDEX', 'user_id'), - 'provider' => array('INDEX', 'oauth_provider'), + 'provider' => array('INDEX', 'oauth_provider'), ), ); $schema_data['phpbb_oauth_accounts'] = array( 'COLUMNS' => array( 'user_id' => array('UINT', 0), - 'provider' => array('VCHAR'), - 'oauth_provider_id' => array('TEXT_UNI'), + 'provider' => array('VCHAR', ''), + 'oauth_provider_id' => array('TEXT_UNI', ''), ), 'PRIMARY_KEY' => array( 'user_id', diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 1eabd2f049..55ddd00d7d 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -132,8 +132,8 @@ CREATE INDEX phpbb_acl_users_auth_role_id ON phpbb_acl_users(auth_role_id);; CREATE TABLE phpbb_oauth_tokens ( user_id INTEGER DEFAULT 0 NOT NULL, session_id CHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, - provider VARCHAR(255) CHARACTER SET NONE NOT NULL, - oauth_token BLOB SUB_TYPE TEXT CHARACTER SET UTF8 NOT NULL + provider VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + oauth_token BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL );; CREATE INDEX phpbb_oauth_tokens_user_id ON phpbb_oauth_tokens(user_id);; @@ -142,8 +142,8 @@ CREATE INDEX phpbb_oauth_tokens_provider ON phpbb_oauth_tokens(oauth_provider);; # Table: 'phpbb_oauth_accounts' CREATE TABLE phpbb_oauth_accounts ( user_id INTEGER DEFAULT 0 NOT NULL, - provider VARCHAR(255) CHARACTER SET NONE NOT NULL, - oauth_provider_id BLOB SUB_TYPE TEXT CHARACTER SET UTF8 NOT NULL + provider VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + oauth_provider_id BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL );; ALTER TABLE phpbb_oauth_accounts ADD PRIMARY KEY (user_id, provider);; diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 36e3910bc8..b2fe8d1710 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -172,8 +172,8 @@ GO CREATE TABLE [phpbb_oauth_tokens] ( [user_id] [int] DEFAULT (0) NOT NULL , [session_id] [char] (32) DEFAULT ('') NOT NULL , - [provider] [varchar] (255) NOT NULL , - [oauth_token] [varchar] (4000) NOT NULL + [provider] [varchar] (255) DEFAULT ('') NOT NULL , + [oauth_token] [varchar] (4000) DEFAULT ('') NOT NULL ) ON [PRIMARY] GO @@ -189,8 +189,8 @@ GO */ CREATE TABLE [phpbb_oauth_accounts] ( [user_id] [int] DEFAULT (0) NOT NULL , - [provider] [varchar] (255) NOT NULL , - [oauth_provider_id] [varchar] (4000) NOT NULL + [provider] [varchar] (255) DEFAULT ('') NOT NULL , + [oauth_provider_id] [varchar] (4000) DEFAULT ('') NOT NULL ) ON [PRIMARY] GO diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index ea9c6419db..9eb2e10e96 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -94,7 +94,7 @@ CREATE TABLE phpbb_acl_users ( CREATE TABLE phpbb_oauth_tokens ( user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, session_id binary(32) DEFAULT '' NOT NULL, - provider varbinary(255) NOT NULL, + provider varbinary(255) DEFAULT '' NOT NULL, oauth_token blob NOT NULL, KEY user_id (user_id), KEY provider (oauth_provider) @@ -104,7 +104,7 @@ CREATE TABLE phpbb_oauth_tokens ( # Table: 'phpbb_oauth_accounts' CREATE TABLE phpbb_oauth_accounts ( user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - provider varbinary(255) NOT NULL, + provider varbinary(255) DEFAULT '' NOT NULL, oauth_provider_id blob NOT NULL, PRIMARY KEY (user_id, provider) ); diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index 0d81f03d17..a4237acb8a 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -94,7 +94,7 @@ CREATE TABLE phpbb_acl_users ( CREATE TABLE phpbb_oauth_tokens ( user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, session_id char(32) DEFAULT '' NOT NULL, - provider varchar(255) NOT NULL, + provider varchar(255) DEFAULT '' NOT NULL, oauth_token text NOT NULL, KEY user_id (user_id), KEY provider (oauth_provider) @@ -104,7 +104,7 @@ CREATE TABLE phpbb_oauth_tokens ( # Table: 'phpbb_oauth_accounts' CREATE TABLE phpbb_oauth_accounts ( user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - provider varchar(255) NOT NULL, + provider varchar(255) DEFAULT '' NOT NULL, oauth_provider_id text NOT NULL, PRIMARY KEY (user_id, provider) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 0868972d2d..6a6d691190 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -216,8 +216,8 @@ CREATE INDEX phpbb_acl_users_auth_role_id ON phpbb_acl_users (auth_role_id) CREATE TABLE phpbb_oauth_tokens ( user_id number(8) DEFAULT '0' NOT NULL, session_id char(32) DEFAULT '' , - provider varchar2(255) NOT NULL, - oauth_token clob NOT NULL + provider varchar2(255) DEFAULT '' , + oauth_token clob DEFAULT '' ) / @@ -231,8 +231,8 @@ CREATE INDEX phpbb_oauth_tokens_provider ON phpbb_oauth_tokens (oauth_provider) */ CREATE TABLE phpbb_oauth_accounts ( user_id number(8) DEFAULT '0' NOT NULL, - provider varchar2(255) NOT NULL, - oauth_provider_id clob NOT NULL, + provider varchar2(255) DEFAULT '' , + oauth_provider_id clob DEFAULT '' , CONSTRAINT pk_phpbb_oauth_accounts PRIMARY KEY (user_id, provider) ) / diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 4b8f8f61e1..135cd23fb8 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -194,8 +194,8 @@ CREATE INDEX phpbb_acl_users_auth_role_id ON phpbb_acl_users (auth_role_id); CREATE TABLE phpbb_oauth_tokens ( user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), session_id char(32) DEFAULT '' NOT NULL, - provider varchar(255) NOT NULL, - oauth_token varchar(4000) NOT NULL + provider varchar(255) DEFAULT '' NOT NULL, + oauth_token varchar(4000) DEFAULT '' NOT NULL ); CREATE INDEX phpbb_oauth_tokens_user_id ON phpbb_oauth_tokens (user_id); @@ -206,8 +206,8 @@ CREATE INDEX phpbb_oauth_tokens_provider ON phpbb_oauth_tokens (oauth_provider); */ CREATE TABLE phpbb_oauth_accounts ( user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), - provider varchar(255) NOT NULL, - oauth_provider_id varchar(4000) NOT NULL, + provider varchar(255) DEFAULT '' NOT NULL, + oauth_provider_id varchar(4000) DEFAULT '' NOT NULL, PRIMARY KEY (user_id, provider) ); diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 3e429850b4..625e19eb98 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -93,8 +93,8 @@ CREATE INDEX phpbb_acl_users_auth_role_id ON phpbb_acl_users (auth_role_id); CREATE TABLE phpbb_oauth_tokens ( user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', session_id char(32) NOT NULL DEFAULT '', - provider varchar(255) NOT NULL , - oauth_token text(65535) NOT NULL + provider varchar(255) NOT NULL DEFAULT '', + oauth_token text(65535) NOT NULL DEFAULT '' ); CREATE INDEX phpbb_oauth_tokens_user_id ON phpbb_oauth_tokens (user_id); @@ -103,8 +103,8 @@ CREATE INDEX phpbb_oauth_tokens_provider ON phpbb_oauth_tokens (oauth_provider); # Table: 'phpbb_oauth_accounts' CREATE TABLE phpbb_oauth_accounts ( user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - provider varchar(255) NOT NULL , - oauth_provider_id text(65535) NOT NULL , + provider varchar(255) NOT NULL DEFAULT '', + oauth_provider_id text(65535) NOT NULL DEFAULT '', PRIMARY KEY (user_id, provider) ); diff --git a/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php b/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php index 5a7f9b5c8d..0d8e8858bb 100644 --- a/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php +++ b/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php @@ -22,23 +22,23 @@ class phpbb_db_migration_data_310_auth_provider_oauth extends phpbb_db_migration 'COLUMNS' => array( 'user_id' => array('UINT', 0), // phpbb_users.user_id 'session_id' => array('CHAR:32', ''), // phpbb_sessions.session_id used only when user_id not set - 'oauth_provider' => array('VCHAR'), // Name of the OAuth provider + 'provider' => array('VCHAR', ''), // Name of the OAuth provider 'oauth_token' => array('TEXT_UNI'), // Serialized token ), 'KEYS' => array( 'user_id' => array('INDEX', 'user_id'), - 'oauth_provider' => array('INDEX', 'oauth_provider'), + 'provider' => array('INDEX', 'oauth_provider'), ), ), $this->table_prefix . 'oauth_accounts' => array( 'COLUMNS' => array( 'user_id' => array('UINT', 0), - 'oauth_provider' => array('VCHAR'), - 'oauth_provider_id' => array('TEXT_UNI'), + 'provider' => array('VCHAR', ''), + 'oauth_provider_id' => array('TEXT_UNI', ''), ), 'PRIMARY_KEY' => array( 'user_id', - 'oauth_provider', + 'provider', ), ), ), -- cgit v1.2.1 From b1c62793c61715b6f5cbfb96b9b02c1bafd76cf7 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Tue, 23 Jul 2013 22:19:48 -0400 Subject: [feature/oauth] Fix token storage after sql changes PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/token_storage.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/token_storage.php b/phpBB/phpbb/auth/provider/oauth/token_storage.php index 385fa58f25..8b6a3de327 100644 --- a/phpBB/phpbb/auth/provider/oauth/token_storage.php +++ b/phpBB/phpbb/auth/provider/oauth/token_storage.php @@ -88,7 +88,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface $data = array( 'user_id' => $this->user->data['user_id'], - 'oauth_provider' => $this->service_name, + 'provider' => $this->service_name, ); if ($this->user->data['user_id'] == ANONYMOUS) @@ -131,7 +131,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface $data = array( 'user_id' => $this->user->data['user_id'], - 'oauth_provider' => $this->service_name, + 'provider' => $this->service_name, 'oauth_token' => serialize($token), ); @@ -156,7 +156,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface $data = array( 'user_id' => $this->user->data['user_id'], - 'oauth_provider' => $this->service_name, + 'provider' => $this->service_name, ); if ($this->user->data['user_id'] == ANONYMOUS) @@ -187,7 +187,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface $sql = 'DELETE FROM ' . $this->auth_provider_oauth_table . ' WHERE user_id = ' . $this->user->data['user_id'] . ' - AND oauth_provider = ' . $this->db->sql_escape($this->oauth_provider); + AND provider = ' . $this->db->sql_escape($this->oauth_provider); if ($this->user->data['user_id'] == ANONYMOUS) { -- cgit v1.2.1 From dc050e7ece74979b093d5249e4283e3959172b43 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Tue, 23 Jul 2013 22:20:26 -0400 Subject: [feature/oauth] Fix OAuth after schema changes PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index c6f7dc223e..2a5e70939c 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -160,7 +160,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base // Check to see if this provider is already assosciated with an account $data = array( - 'oauth_provider' => $service_name, + 'provider' => $service_name, 'oauth_provider_id' => $unique_id ); $sql = 'SELECT user_id FROM' . $this->auth_provider_oauth_token_account_assoc . ' -- cgit v1.2.1 From da6a8787f8443ea02f405a913aa5d0721034f819 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Tue, 23 Jul 2013 22:26:22 -0400 Subject: [feature/oauth] Fix SQL error found in install PHPBB3-11673 --- phpBB/develop/create_schema_files.php | 2 +- phpBB/install/schemas/firebird_schema.sql | 2 +- phpBB/install/schemas/mssql_schema.sql | 2 +- phpBB/install/schemas/mysql_40_schema.sql | 2 +- phpBB/install/schemas/mysql_41_schema.sql | 2 +- phpBB/install/schemas/oracle_schema.sql | 2 +- phpBB/install/schemas/postgres_schema.sql | 2 +- phpBB/install/schemas/sqlite_schema.sql | 2 +- phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) (limited to 'phpBB') diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 6f88b28140..a722a88ff3 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -932,7 +932,7 @@ function get_schema_struct() ), 'KEYS' => array( 'user_id' => array('INDEX', 'user_id'), - 'provider' => array('INDEX', 'oauth_provider'), + 'provider' => array('INDEX', 'provider'), ), ); diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 55ddd00d7d..ce9be26e68 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -137,7 +137,7 @@ CREATE TABLE phpbb_oauth_tokens ( );; CREATE INDEX phpbb_oauth_tokens_user_id ON phpbb_oauth_tokens(user_id);; -CREATE INDEX phpbb_oauth_tokens_provider ON phpbb_oauth_tokens(oauth_provider);; +CREATE INDEX phpbb_oauth_tokens_provider ON phpbb_oauth_tokens(provider);; # Table: 'phpbb_oauth_accounts' CREATE TABLE phpbb_oauth_accounts ( diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index b2fe8d1710..94cfa98784 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -180,7 +180,7 @@ GO CREATE INDEX [user_id] ON [phpbb_oauth_tokens]([user_id]) ON [PRIMARY] GO -CREATE INDEX [provider] ON [phpbb_oauth_tokens]([oauth_provider]) ON [PRIMARY] +CREATE INDEX [provider] ON [phpbb_oauth_tokens]([provider]) ON [PRIMARY] GO diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 9eb2e10e96..fe09756b1e 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -97,7 +97,7 @@ CREATE TABLE phpbb_oauth_tokens ( provider varbinary(255) DEFAULT '' NOT NULL, oauth_token blob NOT NULL, KEY user_id (user_id), - KEY provider (oauth_provider) + KEY provider (provider) ); diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index a4237acb8a..a385010f43 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -97,7 +97,7 @@ CREATE TABLE phpbb_oauth_tokens ( provider varchar(255) DEFAULT '' NOT NULL, oauth_token text NOT NULL, KEY user_id (user_id), - KEY provider (oauth_provider) + KEY provider (provider) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 6a6d691190..f32980e378 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -223,7 +223,7 @@ CREATE TABLE phpbb_oauth_tokens ( CREATE INDEX phpbb_oauth_tokens_user_id ON phpbb_oauth_tokens (user_id) / -CREATE INDEX phpbb_oauth_tokens_provider ON phpbb_oauth_tokens (oauth_provider) +CREATE INDEX phpbb_oauth_tokens_provider ON phpbb_oauth_tokens (provider) / /* diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 135cd23fb8..f64f4981d5 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -199,7 +199,7 @@ CREATE TABLE phpbb_oauth_tokens ( ); CREATE INDEX phpbb_oauth_tokens_user_id ON phpbb_oauth_tokens (user_id); -CREATE INDEX phpbb_oauth_tokens_provider ON phpbb_oauth_tokens (oauth_provider); +CREATE INDEX phpbb_oauth_tokens_provider ON phpbb_oauth_tokens (provider); /* Table: 'phpbb_oauth_accounts' diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 625e19eb98..54f3a132ef 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -98,7 +98,7 @@ CREATE TABLE phpbb_oauth_tokens ( ); CREATE INDEX phpbb_oauth_tokens_user_id ON phpbb_oauth_tokens (user_id); -CREATE INDEX phpbb_oauth_tokens_provider ON phpbb_oauth_tokens (oauth_provider); +CREATE INDEX phpbb_oauth_tokens_provider ON phpbb_oauth_tokens (provider); # Table: 'phpbb_oauth_accounts' CREATE TABLE phpbb_oauth_accounts ( diff --git a/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php b/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php index 0d8e8858bb..febd399c98 100644 --- a/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php +++ b/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php @@ -27,7 +27,7 @@ class phpbb_db_migration_data_310_auth_provider_oauth extends phpbb_db_migration ), 'KEYS' => array( 'user_id' => array('INDEX', 'user_id'), - 'provider' => array('INDEX', 'oauth_provider'), + 'provider' => array('INDEX', 'provider'), ), ), $this->table_prefix . 'oauth_accounts' => array( -- cgit v1.2.1 From 4369cc88762466f16da5aed3bff0037e9d7a46d2 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Tue, 23 Jul 2013 22:29:11 -0400 Subject: [feature/oauth] Fix more errors related to sql changes PHPBB3-11673 --- phpBB/config/tables.yml | 2 +- phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/config/tables.yml b/phpBB/config/tables.yml index a4c730e3bf..0d364eb6b0 100644 --- a/phpBB/config/tables.yml +++ b/phpBB/config/tables.yml @@ -1,5 +1,5 @@ parameters: - tables.auth_provider_oauth_token_storage: %core.table_prefix%oauth_token + tables.auth_provider_oauth_token_storage: %core.table_prefix%oauth_tokens tables.auth_provider_oauth_account_assoc: %core.table_prefix%oauth_accounts tables.config: %core.table_prefix%config tables.config_text: %core.table_prefix%config_text diff --git a/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php b/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php index febd399c98..5e3fa919e8 100644 --- a/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php +++ b/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php @@ -18,7 +18,7 @@ class phpbb_db_migration_data_310_auth_provider_oauth extends phpbb_db_migration { return array( 'add_tables' => array( - $this->table_prefix . 'oauth_token' => array( + $this->table_prefix . 'oauth_tokens' => array( 'COLUMNS' => array( 'user_id' => array('UINT', 0), // phpbb_users.user_id 'session_id' => array('CHAR:32', ''), // phpbb_sessions.session_id used only when user_id not set -- cgit v1.2.1 From 5fa08b92a29d7349c089eab33b4c38513ef964fd Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Tue, 23 Jul 2013 22:32:59 -0400 Subject: [feature/oauth] Fix typo in token storage PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/token_storage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/token_storage.php b/phpBB/phpbb/auth/provider/oauth/token_storage.php index 8b6a3de327..42142b4fbe 100644 --- a/phpBB/phpbb/auth/provider/oauth/token_storage.php +++ b/phpBB/phpbb/auth/provider/oauth/token_storage.php @@ -83,7 +83,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface public function retrieveAccessToken() { if( $this->cachedToken instanceOf TokenInterface ) { - return $this->token; + return $this->cachedToken; } $data = array( -- cgit v1.2.1 From 38d4eb073e1915f60cb4c9912d7567cf032e0776 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Tue, 23 Jul 2013 22:35:34 -0400 Subject: [feature/oauth] Fix last typo. Authentication works for accounts in db PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 2a5e70939c..39657011c2 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -163,7 +163,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base 'provider' => $service_name, 'oauth_provider_id' => $unique_id ); - $sql = 'SELECT user_id FROM' . $this->auth_provider_oauth_token_account_assoc . ' + $sql = 'SELECT user_id FROM ' . $this->auth_provider_oauth_token_account_assoc . ' WHERE ' . $this->db->sql_build_array('SELECT', $data); $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); -- cgit v1.2.1 From 5401673f965aaef7048797d1f696bd5e43bbfaf6 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 24 Jul 2013 10:35:36 -0400 Subject: [feature/oauth] Move language constants for oauth services to common.php PHPBB3-11673 --- phpBB/language/en/acp/board.php | 3 --- phpBB/language/en/common.php | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index f76834ae50..abc7738ee3 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -397,9 +397,6 @@ $lang = array_merge($lang, array( 'AUTH_PROVIDER_OAUTH_ERROR_ELEMENT_MISSING' => 'Both the key and secret of each enabled OAuth service provider must be provided. Only one was provided for an OAuth service provider.', 'AUTH_PROVIDER_OAUTH_EXPLAIN' => 'Each OAuth provider requires a unique secret and key in order to authenticate with the external server.
These should be supplied by the OAuth service when you register your website with them and should be entered exactly as provided to you.
Any service that does not have both a key and a secret entered here will not be available for use by the forum users.', 'AUTH_PROVIDER_OAUTH_KEY' => 'Key', - 'AUTH_PROVIDER_OAUTH_SERVICE_BITLY' => 'Bitly', - 'AUTH_PROVIDER_OAUTH_SERVICE_FACEBOOK' => 'Facebook', - 'AUTH_PROVIDER_OAUTH_SERVICE_GOOGLE' => 'Google', 'AUTH_PROVIDER_OAUTH_TITLE' => 'OAuth', 'AUTH_PROVIDER_OAUTH_SECRET' => 'Secret', diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index a68c027554..0b658f22b6 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -88,6 +88,9 @@ $lang = array_merge($lang, array( 'ATTACHED_IMAGE_NOT_IMAGE' => 'The image file you tried to attach is invalid.', 'AUTHOR' => 'Author', 'AUTH_NO_PROFILE_CREATED' => 'The creation of a user profile was unsuccessful.', + 'AUTH_PROVIDER_OAUTH_SERVICE_BITLY' => 'Bitly', + 'AUTH_PROVIDER_OAUTH_SERVICE_FACEBOOK' => 'Facebook', + 'AUTH_PROVIDER_OAUTH_SERVICE_GOOGLE' => 'Google', 'AVATAR_DISALLOWED_CONTENT' => 'The upload was rejected because the uploaded file was identified as a possible attack vector.', 'AVATAR_DISALLOWED_EXTENSION' => 'This file cannot be displayed because the extension %s is not allowed.', 'AVATAR_EMPTY_REMOTE_DATA' => 'The specified avatar could not be uploaded because the remote data appears to be invalid or corrupted.', -- cgit v1.2.1 From ffb14a69887e0410c5093f23142bbc3375552620 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 24 Jul 2013 10:36:08 -0400 Subject: [feature/oauth] Fix OAuth login PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 39657011c2..6e822101e3 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -160,7 +160,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base // Check to see if this provider is already assosciated with an account $data = array( - 'provider' => $service_name, + 'provider' => $service_name_original, 'oauth_provider_id' => $unique_id ); $sql = 'SELECT user_id FROM ' . $this->auth_provider_oauth_token_account_assoc . ' -- cgit v1.2.1 From 58d5820069a5889ae2f09319ae4f972c8b8f87a8 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 24 Jul 2013 10:39:48 -0400 Subject: [feature/oauth] Basic login functionality now working These changes are currently unique to OAuth and need to be made generic so that any auth provider can modify the login template. PHPBB3-11673 --- phpBB/includes/functions.php | 7 ++----- phpBB/phpbb/auth/provider/oauth/oauth.php | 11 ++++++----- 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index b14f03f5a0..02cdfd7ed1 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3373,12 +3373,9 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa { $auth_provider = $phpbb_container->get('auth.provider.oauth'); $oauth_box_data = $auth_provider->get_login_data(); - foreach ($oauth_box_data as $service_name => $data) + foreach ($oauth_box_data as $data) { - $template->assign_block_vars('oauth', array( - 'SERVICE_NAME' => $service_name, - 'REDIRECT_URL' => $data['url'], - )); + $template->assign_block_vars('oauth', $data); } } diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 6e822101e3..0762e202db 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -272,11 +272,12 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base $credentials = $service_provider->get_service_credentials(); if ($credentials['key'] && $credentials['secret']) { - $login_data[$service_provider] = array(); - - // Build the redirect url for the box - $redirect_url = build_url(false) . '&oauth_service=' . $service_name; - $login_data[$service_provider]['url'] = redirect($redirect_url, true); + $actual_name = str_replace('auth.provider.oauth.service.', '', $service_name); + $redirect_url = build_url(false) . '&login=external&oauth_service=' . $actual_name; + $login_data[$service_name] = array( + 'REDIRECT_URL' => redirect($redirect_url, true), + 'SERVICE_NAME' => $this->user->lang['AUTH_PROVIDER_OAUTH_SERVICE_' . strtoupper($actual_name)], + ); } } -- cgit v1.2.1 From 669586c134641b29a95faa43090df124b59d4e14 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 24 Jul 2013 12:55:43 -0400 Subject: [feature/oauth] Token must be updated with the user_id PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 0762e202db..90ce1f8f5a 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -171,8 +171,8 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base if (!$row) { - // Account not tied to any existing account - // TODO: determine action that should occur + // The user does not yet exist, ask if they wish to register the account + throw new Exception($unique_id); } // Retrieve the user's account @@ -189,6 +189,9 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base throw new Exception('Invalid entry in ' . $this->auth_provider_oauth_token_account_assoc); } + // Update token storage to store the user_id + $storage->set_user_id($row['user_id']); + // The user is now authenticated and can be logged in return array( 'status' => LOGIN_SUCCESS, -- cgit v1.2.1 From 98b385bc1c14a3155dd429f8d9118f4d7eb95556 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 11:59:21 -0500 Subject: [ticket/11628] Remove style resource locator No longer used since Twig was implemented. PHPBB3-11628 --- phpBB/config/services.yml | 4 - phpBB/includes/bbcode.php | 3 +- phpBB/install/index.php | 3 +- phpBB/phpbb/style/resource_locator.php | 348 --------------------------------- phpBB/phpbb/style/style.php | 45 +---- phpBB/phpbb/template/locator.php | 163 --------------- 6 files changed, 3 insertions(+), 563 deletions(-) delete mode 100644 phpBB/phpbb/style/resource_locator.php delete mode 100644 phpBB/phpbb/template/locator.php (limited to 'phpBB') diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 8abc413a5a..4902f4b6f6 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -258,13 +258,9 @@ services: - %core.php_ext% - @config - @user - - @style.resource_locator - @style.path_provider_ext - @template - style.resource_locator: - class: phpbb_style_resource_locator - style.path_provider_ext: class: phpbb_style_extension_path_provider arguments: diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index fd00728510..4ce6f17d90 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -132,10 +132,9 @@ class bbcode { $this->template_bitfield = new bitfield($user->style['bbcode_bitfield']); - $style_resource_locator = new phpbb_style_resource_locator(); $style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider(), $phpbb_root_path); $template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context(), $phpbb_extension_manager); - $style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, $style_path_provider, $template); + $style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_path_provider, $template); $style->set_style(); $template->set_filenames(array('bbcode.html' => 'bbcode.html')); $this->template_filename = $template->get_source_file_for_handle('bbcode.html'); diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 45e5777e36..f924b05547 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -212,10 +212,9 @@ $config = new phpbb_config(array( 'load_tplcompile' => '1' )); -$phpbb_style_resource_locator = new phpbb_style_resource_locator(); $phpbb_style_path_provider = new phpbb_style_path_provider(); $template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context()); -$phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider, $template); +$phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_path_provider, $template); $phpbb_style->set_ext_dir_prefix('adm/'); $phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); $template->assign_var('T_ASSETS_PATH', '../assets'); diff --git a/phpBB/phpbb/style/resource_locator.php b/phpBB/phpbb/style/resource_locator.php deleted file mode 100644 index 4cf767c062..0000000000 --- a/phpBB/phpbb/style/resource_locator.php +++ /dev/null @@ -1,348 +0,0 @@ -set_default_template_path(); - } - - /** - * Sets the list of style paths - * - * These paths will be searched for style files in the provided order. - * Paths may be outside of phpBB, but templates loaded from these paths - * will still be cached. - * - * @param array $style_paths An array of paths to style directories - * @return null - */ - public function set_paths($style_paths) - { - $this->roots = array(); - $this->files = array(); - $this->filenames = array(); - - foreach ($style_paths as $key => $paths) - { - foreach ($paths as $path) - { - // Make sure $path has no ending slash - if (substr($path, -1) === '/') - { - $path = substr($path, 0, -1); - } - $this->roots[$key][] = $path; - } - } - } - - /** - * Sets the location of templates directory within style directories. - * - * The location must be a relative path, with a trailing slash. - * Typically it is one directory level deep, e.g. "template/". - * - * @param string $template_path Relative path to templates directory within style directories - * @return null - */ - public function set_template_path($template_path) - { - $this->template_path = $template_path; - } - - /** - * Sets the location of templates directory within style directories - * to the default, which is "template/". - * - * @return null - */ - public function set_default_template_path() - { - $this->template_path = 'template/'; - } - - /** - * {@inheritDoc} - */ - public function set_filenames(array $filename_array) - { - foreach ($filename_array as $handle => $filename) - { - if (empty($filename)) - { - trigger_error("style resource locator: set_filenames: Empty filename specified for $handle", E_USER_ERROR); - } - - $this->filename[$handle] = $filename; - - foreach ($this->roots as $root_key => $root_paths) - { - foreach ($root_paths as $root_index => $root) - { - $this->files[$root_key][$root_index][$handle] = $root . '/' . $this->template_path . $filename; - } - } - } - } - - /** - * {@inheritDoc} - */ - public function get_filename_for_handle($handle) - { - if (!isset($this->filename[$handle])) - { - trigger_error("style resource locator: get_filename_for_handle: No file specified for handle $handle", E_USER_ERROR); - } - return $this->filename[$handle]; - } - - /** - * {@inheritDoc} - */ - public function get_virtual_source_file_for_handle($handle) - { - // If we don't have a file assigned to this handle, die. - if (!isset($this->files['style'][0][$handle])) - { - trigger_error("style resource locator: No file specified for handle $handle", E_USER_ERROR); - } - - $source_file = $this->files['style'][0][$handle]; - return $source_file; - } - - /** - * {@inheritDoc} - */ - public function get_source_file_for_handle($handle, $find_all = false) - { - // If we don't have a file assigned to this handle, die. - if (!isset($this->files['style'][0][$handle])) - { - trigger_error("style resource locator: No file specified for handle $handle", E_USER_ERROR); - } - - // locate a source file that exists - $source_file = $this->files['style'][0][$handle]; - $tried = $source_file; - $found = false; - $found_all = array(); - foreach ($this->roots as $root_key => $root_paths) - { - foreach ($root_paths as $root_index => $root) - { - $source_file = $this->files[$root_key][$root_index][$handle]; - $tried .= ', ' . $source_file; - if (file_exists($source_file)) - { - $found = true; - break; - } - } - if ($found) - { - if ($find_all) - { - $found_all[] = $source_file; - $found = false; - } - else - { - break; - } - } - } - - // search failed - if (!$found && !$find_all) - { - trigger_error("style resource locator: File for handle $handle does not exist. Could not find: $tried", E_USER_ERROR); - } - - return ($find_all) ? $found_all : $source_file; - } - - /** - * {@inheritDoc} - */ - public function get_first_file_location($files, $return_default = false, $return_full_path = true) - { - // set default value - $default_result = false; - - // check all available paths - foreach ($this->roots as $root_paths) - { - foreach ($root_paths as $path) - { - // check all files - foreach ($files as $filename) - { - $source_file = $path . '/' . $filename; - if (file_exists($source_file)) - { - return ($return_full_path) ? $source_file : $filename; - } - - // assign first file as result if $return_default is true - if ($return_default && $default_result === false) - { - $default_result = $source_file; - } - } - } - } - - // search failed - return $default_result; - } - - /** - * Obtains filesystem path for a template file. - * - * The simplest use is specifying a single template file as a string - * in the first argument. This template file should be a basename - * of a template file in the selected style, or its parent styles - * if template inheritance is being utilized. - * - * Note: "selected style" is whatever style the style resource locator - * is configured for. - * - * The return value then will be a path, relative to the current - * directory or absolute, to the template file in the selected style - * or its closest parent. - * - * If the selected style does not have the template file being searched, - * (and if inheritance is involved, none of the parents have it either), - * false will be returned. - * - * Specifying true for $return_default will cause the function to - * return the first path which was checked for existence in the event - * that the template file was not found, instead of false. - * This is the path in the selected style itself, not any of its - * parents. - * - * $files can be given an array of templates instead of a single - * template. When given an array, the function will try to resolve - * each template in the array to a path, and will return the first - * path that exists, or false if none exist. - * - * If $files is an array and template inheritance is involved, first - * each of the files will be checked in the selected style, then each - * of the files will be checked in the immediate parent, and so on. - * - * If $return_full_path is false, then instead of returning a usable - * path (when the template is found) only the template's basename - * will be returned. This can be used to check which of the templates - * specified in $files exists. Naturally more than one template must - * be given in $files. - * - * This function works identically to get_first_file_location except - * it operates on a list of templates, not files. Practically speaking, - * the templates given in the first argument first are prepended with - * the template path (property in this class), then given to - * get_first_file_location for the rest of the processing. - * - * Templates given to this function can be relative paths for templates - * located in subdirectories of the template directories. The paths - * should be relative to the templates directory (template/ by default). - * - * @param string or array $files List of templates to locate. If there is only - * one template, $files can be a string to make code easier to read. - * @param bool $return_default Determines what to return if template does not - * exist. If true, function will return location where template is - * supposed to be. If false, function will return false. - * @param bool $return_full_path If true, function will return full path - * to template. If false, function will return template file name. - * This parameter can be used to check which one of set of template - * files is available. - * @return string or boolean Source template path if template exists or $return_default is - * true. False if template does not exist and $return_default is false - */ - public function get_first_template_location($templates, $return_default = false, $return_full_path = true) - { - // add template path prefix - $files = array(); - if (is_string($templates)) - { - $files[] = $this->template_path . $templates; - } - else - { - foreach ($templates as $template) - { - $files[] = $this->template_path . $template; - } - } - - return $this->get_first_file_location($files, $return_default, $return_full_path); - } -} diff --git a/phpBB/phpbb/style/style.php b/phpBB/phpbb/style/style.php index 034f518091..9756fb74ac 100644 --- a/phpBB/phpbb/style/style.php +++ b/phpBB/phpbb/style/style.php @@ -52,12 +52,6 @@ class phpbb_style */ private $user; - /** - * Style resource locator - * @var phpbb_style_resource_locator - */ - private $locator; - /** * Style path provider * @var phpbb_style_path_provider @@ -69,17 +63,15 @@ class phpbb_style * * @param string $phpbb_root_path phpBB root path * @param user $user current user - * @param phpbb_style_resource_locator $locator style resource locator * @param phpbb_style_path_provider $provider style path provider * @param phpbb_template $template template */ - public function __construct($phpbb_root_path, $php_ext, $config, $user, phpbb_style_resource_locator $locator, phpbb_style_path_provider_interface $provider, phpbb_template $template) + public function __construct($phpbb_root_path, $php_ext, $config, $user, phpbb_style_path_provider_interface $provider, phpbb_template $template) { $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; $this->config = $config; $this->user = $user; - $this->locator = $locator; $this->provider = $provider; $this->template = $template; } @@ -130,7 +122,6 @@ class phpbb_style } $this->provider->set_styles($paths); - $this->locator->set_paths($this->provider); $new_paths = array(); foreach ($paths as $path) @@ -168,12 +159,6 @@ class phpbb_style $this->names = $names; $this->provider->set_styles($paths); - $this->locator->set_paths($this->provider); - - if ($template_path !== false) - { - $this->locator->set_template_path($template_path); - } $new_paths = array(); foreach ($paths as $path) @@ -210,32 +195,4 @@ class phpbb_style { $this->provider->set_ext_dir_prefix($ext_dir_prefix); } - - /** - * Locates source file path, accounting for styles tree and verifying that - * the path exists. - * - * @param string or array $files List of files to locate. If there is only - * one file, $files can be a string to make code easier to read. - * @param bool $return_default Determines what to return if file does not - * exist. If true, function will return location where file is - * supposed to be. If false, function will return false. - * @param bool $return_full_path If true, function will return full path - * to file. If false, function will return file name. This - * parameter can be used to check which one of set of files - * is available. - * @return string or boolean Source file path if file exists or $return_default is - * true. False if file does not exist and $return_default is false - */ - public function locate($files, $return_default = false, $return_full_path = true) - { - // convert string to array - if (is_string($files)) - { - $files = array($files); - } - - // use resource locator to find files - return $this->locator->get_first_file_location($files, $return_default, $return_full_path); - } } diff --git a/phpBB/phpbb/template/locator.php b/phpBB/phpbb/template/locator.php deleted file mode 100644 index f6fd20bcc2..0000000000 --- a/phpBB/phpbb/template/locator.php +++ /dev/null @@ -1,163 +0,0 @@ - filename pairs. - * - * @param array $filename_array Should be a hash of handle => filename pairs. - */ - public function set_filenames(array $filename_array); - - /** - * Determines the filename for a template handle. - * - * The filename comes from array used in a set_filenames call, - * which should have been performed prior to invoking this function. - * Return value is a file basename (without path). - * - * @param $handle string Template handle - * @return string Filename corresponding to the template handle - */ - public function get_filename_for_handle($handle); - - /** - * Determines the source file path for a template handle without - * regard for styles tree. - * - * This function returns the path in "primary" style directory - * corresponding to the given template handle. That path may or - * may not actually exist on the filesystem. Because this function - * does not perform stat calls to determine whether the path it - * returns actually exists, it is faster than get_source_file_for_handle. - * - * Use get_source_file_for_handle to obtain the actual path that is - * guaranteed to exist (which might come from the parent style - * directory if primary style has parent styles). - * - * This function will trigger an error if the handle was never - * associated with a template file via set_filenames. - * - * @param $handle string Template handle - * @return string Path to source file path in primary style directory - */ - public function get_virtual_source_file_for_handle($handle); - - /** - * Determines the source file path for a template handle, accounting - * for styles tree and verifying that the path exists. - * - * This function returns the actual path that may be compiled for - * the specified template handle. It will trigger an error if - * the template handle was never associated with a template path - * via set_filenames or if the template file does not exist on the - * filesystem. - * - * Use get_virtual_source_file_for_handle to just resolve a template - * handle to a path without any filesystem or styles tree checks. - * - * @param string $handle Template handle (i.e. "friendly" template name) - * @param bool $find_all If true, each root path will be checked and function - * will return array of files instead of string and will not - * trigger a error if template does not exist - * @return string Source file path - */ - public function get_source_file_for_handle($handle, $find_all = false); - - /** - * Obtains a complete filesystem path for a file in a style. - * - * This function traverses the style tree (selected style and - * its parents in order, if inheritance is being used) and finds - * the first file on the filesystem matching specified relative path, - * or the first of the specified paths if more than one path is given. - * - * This function can be used to determine filesystem path of any - * file under any style, with the consequence being that complete - * relative to the style directory path must be provided as an argument. - * - * In particular, this function can be used to locate templates - * and javascript files. - * - * For locating templates get_first_template_location should be used - * as it prepends the configured template path to the template basename. - * - * Note: "selected style" is whatever style the style resource locator - * is configured for. - * - * The return value then will be a path, relative to the current - * directory or absolute, to the first existing file in the selected - * style or its closest parent. - * - * If the selected style does not have the file being searched, - * (and if inheritance is involved, none of the parents have it either), - * false will be returned. - * - * Multiple files can be specified, in which case the first file in - * the list that can be found on the filesystem is returned. - * - * If multiple files are specified and inheritance is involved, - * first each of the specified files is checked in the selected style, - * then each of the specified files is checked in the immediate parent, - * etc. - * - * Specifying true for $return_default will cause the function to - * return the first path which was checked for existence in the event - * that the template file was not found, instead of false. - * This is always a path in the selected style itself, not any of its - * parents. - * - * If $return_full_path is false, then instead of returning a usable - * path (when the file is found) the file's path relative to the style - * directory will be returned. This is the same path as was given to - * the function as a parameter. This can be used to check which of the - * files specified in $files exists. Naturally this requires passing - * more than one file in $files. - * - * @param array $files List of files to locate. - * @param bool $return_default Determines what to return if file does not - * exist. If true, function will return location where file is - * supposed to be. If false, function will return false. - * @param bool $return_full_path If true, function will return full path - * to file. If false, function will return file name. This - * parameter can be used to check which one of set of files - * is available. - * @return string or boolean Source file path if file exists or $return_default is - * true. False if file does not exist and $return_default is false - */ - public function get_first_file_location($files, $return_default = false, $return_full_path = true); -} -- cgit v1.2.1 From 44a82dd0837a4693b6a4a410c21c438f244094d3 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 12:05:04 -0500 Subject: [ticket/11628] Remove style path provider No longer used since Twig was implemented. PHPBB3-11628 --- phpBB/config/services.yml | 11 --- phpBB/includes/bbcode.php | 3 +- phpBB/install/index.php | 4 +- phpBB/phpbb/style/extension_path_provider.php | 137 -------------------------- phpBB/phpbb/style/path_provider.php | 62 ------------ phpBB/phpbb/style/path_provider_interface.php | 42 -------- phpBB/phpbb/style/style.php | 25 +---- 7 files changed, 3 insertions(+), 281 deletions(-) delete mode 100644 phpBB/phpbb/style/extension_path_provider.php delete mode 100644 phpBB/phpbb/style/path_provider.php delete mode 100644 phpBB/phpbb/style/path_provider_interface.php (limited to 'phpBB') diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 4902f4b6f6..7acc44f24d 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -258,19 +258,8 @@ services: - %core.php_ext% - @config - @user - - @style.path_provider_ext - @template - style.path_provider_ext: - class: phpbb_style_extension_path_provider - arguments: - - @ext.manager - - @style.path_provider - - %core.root_path% - - style.path_provider: - class: phpbb_style_path_provider - template: class: phpbb_template_twig arguments: diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index 4ce6f17d90..9b1939030a 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -132,9 +132,8 @@ class bbcode { $this->template_bitfield = new bitfield($user->style['bbcode_bitfield']); - $style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider(), $phpbb_root_path); $template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context(), $phpbb_extension_manager); - $style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_path_provider, $template); + $style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $template); $style->set_style(); $template->set_filenames(array('bbcode.html' => 'bbcode.html')); $this->template_filename = $template->get_source_file_for_handle('bbcode.html'); diff --git a/phpBB/install/index.php b/phpBB/install/index.php index f924b05547..46660723ba 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -212,10 +212,8 @@ $config = new phpbb_config(array( 'load_tplcompile' => '1' )); -$phpbb_style_path_provider = new phpbb_style_path_provider(); $template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context()); -$phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_path_provider, $template); -$phpbb_style->set_ext_dir_prefix('adm/'); +$phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $template); $phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); $template->assign_var('T_ASSETS_PATH', '../assets'); $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style'); diff --git a/phpBB/phpbb/style/extension_path_provider.php b/phpBB/phpbb/style/extension_path_provider.php deleted file mode 100644 index ec1d85f821..0000000000 --- a/phpBB/phpbb/style/extension_path_provider.php +++ /dev/null @@ -1,137 +0,0 @@ -base_path_provider = $base_path_provider; - $this->phpbb_root_path = $phpbb_root_path; - } - - /** - * Sets a prefix for style paths searched within extensions. - * - * The prefix is inserted between the extension's path e.g. ext/foo/ and - * the looked up style path, e.g. styles/bar/. So it should not have a - * leading slash, but should have a trailing slash. - * - * @param string $ext_dir_prefix The prefix including trailing slash - * @return null - */ - public function set_ext_dir_prefix($ext_dir_prefix) - { - $this->ext_dir_prefix = $ext_dir_prefix; - } - - /** - * Finds style paths using the extension manager - * - * Locates a path (e.g. styles/prosilver/) in all active extensions. - * Then appends the core style paths based in the current working - * directory. - * - * @return array List of style paths - */ - public function find() - { - $directories = array(); - - $finder = $this->extension_manager->get_finder(); - foreach ($this->base_path_provider as $key => $paths) - { - if ($key == 'style') - { - foreach ($paths as $path) - { - $directories['style'][] = $path; - if ($path && !phpbb_is_absolute($path)) - { - // Remove phpBB root path from the style path, - // so the finder is able to find extension styles, - // when the root path is not ./ - if (strpos($path, $this->phpbb_root_path) === 0) - { - $path = substr($path, strlen($this->phpbb_root_path)); - } - - $result = $finder->directory('/' . $this->ext_dir_prefix . $path) - ->get_directories(true, false, true); - foreach ($result as $ext => $ext_path) - { - // Make sure $ext_path has no ending slash - if (substr($ext_path, -1) === '/') - { - $ext_path = substr($ext_path, 0, -1); - } - $directories[$ext][] = $ext_path; - } - } - } - } - } - - return $directories; - } - - /** - * Overwrites the current style paths - * - * @param array $styles An array of style paths. The first element is the main style. - * @return null - */ - public function set_styles(array $styles) - { - $this->base_path_provider->set_styles($styles); - $this->items = null; - } -} diff --git a/phpBB/phpbb/style/path_provider.php b/phpBB/phpbb/style/path_provider.php deleted file mode 100644 index 731d682e88..0000000000 --- a/phpBB/phpbb/style/path_provider.php +++ /dev/null @@ -1,62 +0,0 @@ -paths = array('style' => $styles); - } - - /** - * Retrieve an iterator over all style paths - * - * @return ArrayIterator An iterator for the array of style paths - */ - public function getIterator() - { - return new ArrayIterator($this->paths); - } -} diff --git a/phpBB/phpbb/style/path_provider_interface.php b/phpBB/phpbb/style/path_provider_interface.php deleted file mode 100644 index 1a6153a4d3..0000000000 --- a/phpBB/phpbb/style/path_provider_interface.php +++ /dev/null @@ -1,42 +0,0 @@ -phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; $this->config = $config; $this->user = $user; - $this->provider = $provider; $this->template = $template; } @@ -121,8 +113,6 @@ class phpbb_style } } - $this->provider->set_styles($paths); - $new_paths = array(); foreach ($paths as $path) { @@ -158,8 +148,6 @@ class phpbb_style } $this->names = $names; - $this->provider->set_styles($paths); - $new_paths = array(); foreach ($paths as $path) { @@ -184,15 +172,4 @@ class phpbb_style { return $this->phpbb_root_path . trim($style_base_directory, '/') . '/' . $path; } - - /** - * Defines a prefix to use for style paths in extensions - * - * @param string $ext_dir_prefix The prefix including trailing slash - * @return null - */ - public function set_ext_dir_prefix($ext_dir_prefix) - { - $this->provider->set_ext_dir_prefix($ext_dir_prefix); - } } -- cgit v1.2.1 From 5d1afb453211d42a8deacb66684c136385918192 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 12:24:35 -0500 Subject: [ticket/11628] Remove phpbb_style (move methods to phpbb_template) PHPBB3-11628 --- phpBB/adm/index.php | 2 +- phpBB/adm/swatch.php | 2 +- phpBB/common.php | 1 - phpBB/config/services.yml | 11 +-- phpBB/includes/bbcode.php | 3 +- phpBB/includes/functions_module.php | 6 +- phpBB/install/index.php | 3 +- phpBB/install/install_update.php | 4 +- phpBB/phpbb/controller/resolver.php | 16 ++-- phpBB/phpbb/style/style.php | 175 ------------------------------------ phpBB/phpbb/template/template.php | 30 +++++++ phpBB/phpbb/template/twig/twig.php | 107 +++++++++++++++++++++- phpBB/phpbb/user.php | 4 +- 13 files changed, 156 insertions(+), 208 deletions(-) delete mode 100644 phpBB/phpbb/style/style.php (limited to 'phpBB') diff --git a/phpBB/adm/index.php b/phpBB/adm/index.php index 8cd1967c75..3f29072899 100644 --- a/phpBB/adm/index.php +++ b/phpBB/adm/index.php @@ -50,7 +50,7 @@ $module_id = request_var('i', ''); $mode = request_var('mode', ''); // Set custom style for admin area -$phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); +$template->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); $template->assign_var('T_ASSETS_PATH', $phpbb_root_path . 'assets'); $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style'); diff --git a/phpBB/adm/swatch.php b/phpBB/adm/swatch.php index 3ae38d0d8b..70441ffeed 100644 --- a/phpBB/adm/swatch.php +++ b/phpBB/adm/swatch.php @@ -22,7 +22,7 @@ $auth->acl($user->data); $user->setup(); // Set custom template for admin area -$phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); +$template->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); $template->set_filenames(array( 'body' => 'colour_swatch.html') diff --git a/phpBB/common.php b/phpBB/common.php index 962a1f951f..6a1f307d64 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -121,7 +121,6 @@ $phpbb_extension_manager = $phpbb_container->get('ext.manager'); $phpbb_subscriber_loader = $phpbb_container->get('event.subscriber_loader'); $template = $phpbb_container->get('template'); -$phpbb_style = $phpbb_container->get('style'); // Add own hook handler require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 7acc44f24d..d0753322da 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -98,7 +98,7 @@ services: arguments: - @user - @service_container - - @style + - @template cron.task_collection: class: phpbb_di_service_collection @@ -251,15 +251,6 @@ services: request: class: phpbb_request - style: - class: phpbb_style - arguments: - - %core.root_path% - - %core.php_ext% - - @config - - @user - - @template - template: class: phpbb_template_twig arguments: diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index 9b1939030a..2fa6a8b099 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -133,8 +133,7 @@ class bbcode $this->template_bitfield = new bitfield($user->style['bbcode_bitfield']); $template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context(), $phpbb_extension_manager); - $style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $template); - $style->set_style(); + $template->set_style(); $template->set_filenames(array('bbcode.html' => 'bbcode.html')); $this->template_filename = $template->get_source_file_for_handle('bbcode.html'); } diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index 99c24fcb19..a5ece1ecac 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -455,7 +455,7 @@ class p_master */ function load_active($mode = false, $module_url = false, $execute_module = true) { - global $phpbb_root_path, $phpbb_admin_path, $phpEx, $user, $phpbb_style; + global $phpbb_root_path, $phpbb_admin_path, $phpEx, $user, $template; $module_path = $this->include_path . $this->p_class; $icat = request_var('icat', ''); @@ -508,7 +508,7 @@ class p_master if (is_dir($module_style_dir)) { - $phpbb_style->set_custom_style('admin', array($module_style_dir, $phpbb_admin_path . 'style'), array(), ''); + $template->set_custom_style('admin', array($module_style_dir, $phpbb_admin_path . 'style'), array(), ''); } } @@ -537,7 +537,7 @@ class p_master if (is_dir($phpbb_root_path . $module_style_dir)) { - $phpbb_style->set_style(array($module_style_dir, 'styles')); + $template->set_style(array($module_style_dir, 'styles')); } } diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 46660723ba..fd0d8a2d48 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -213,8 +213,7 @@ $config = new phpbb_config(array( )); $template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context()); -$phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $template); -$phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); +$template->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); $template->assign_var('T_ASSETS_PATH', '../assets'); $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style'); diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index df9b6c1c7e..51fbd1975c 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -71,7 +71,7 @@ class install_update extends module function main($mode, $sub) { - global $phpbb_style, $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language; + global $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language; global $request, $phpbb_admin_path, $phpbb_adm_relative_path, $phpbb_container; // Create a normal container now @@ -138,7 +138,7 @@ class install_update extends module } // Set custom template again. ;) - $phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); + $template->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); $template->assign_vars(array( 'S_USER_LANG' => $user->lang['USER_LANG'], diff --git a/phpBB/phpbb/controller/resolver.php b/phpBB/phpbb/controller/resolver.php index 95dfc8da8e..850df84a0f 100644 --- a/phpBB/phpbb/controller/resolver.php +++ b/phpBB/phpbb/controller/resolver.php @@ -38,23 +38,23 @@ class phpbb_controller_resolver implements ControllerResolverInterface protected $container; /** - * phpbb_style object - * @var phpbb_style + * phpbb_template object + * @var phpbb_template */ - protected $style; + protected $template; /** * Construct method * * @param phpbb_user $user User Object * @param ContainerInterface $container ContainerInterface object - * @param phpbb_style $style + * @param phpbb_template_interface $template */ - public function __construct(phpbb_user $user, ContainerInterface $container, phpbb_style $style = null) + public function __construct(phpbb_user $user, ContainerInterface $container, phpbb_template $template = null) { $this->user = $user; $this->container = $container; - $this->style = $style; + $this->template = $template; } /** @@ -96,13 +96,13 @@ class phpbb_controller_resolver implements ControllerResolverInterface $controller_dir = explode('_', get_class($controller_object)); // 0 phpbb, 1 ext, 2 vendor, 3 extension name, ... - if (!is_null($this->style) && isset($controller_dir[3]) && $controller_dir[1] === 'ext') + if (!is_null($this->template) && isset($controller_dir[3]) && $controller_dir[1] === 'ext') { $controller_style_dir = 'ext/' . $controller_dir[2] . '/' . $controller_dir[3] . '/styles'; if (is_dir($controller_style_dir)) { - $this->style->set_style(array($controller_style_dir, 'styles')); + $this->template->set_style(array($controller_style_dir, 'styles')); } } diff --git a/phpBB/phpbb/style/style.php b/phpBB/phpbb/style/style.php deleted file mode 100644 index 283e3015ca..0000000000 --- a/phpBB/phpbb/style/style.php +++ /dev/null @@ -1,175 +0,0 @@ -phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - $this->config = $config; - $this->user = $user; - $this->template = $template; - } - - /** - * Get the style tree of the style preferred by the current user - * - * @return array Style tree, most specific first - */ - public function get_user_style() - { - $style_list = array( - $this->user->style['style_path'], - ); - - if ($this->user->style['style_parent_id']) - { - $style_list = array_merge($style_list, array_reverse(explode('/', $this->user->style['style_parent_tree']))); - } - - return $style_list; - } - - /** - * Set style location based on (current) user's chosen style. - * - * @param array $style_directories The directories to add style paths for - * E.g. array('ext/foo/bar/styles', 'styles') - * Default: array('styles') (phpBB's style directory) - * @return bool true - */ - public function set_style($style_directories = array('styles')) - { - $this->names = $this->get_user_style(); - - $paths = array(); - foreach ($style_directories as $directory) - { - foreach ($this->names as $name) - { - $path = $this->get_style_path($name, $directory); - - if (is_dir($path)) - { - $paths[] = $path; - } - } - } - - $new_paths = array(); - foreach ($paths as $path) - { - $new_paths[] = $path . '/template/'; - } - - $this->template->set_style_names($this->names, $new_paths, ($style_directories === array('styles'))); - - return true; - } - - /** - * Set custom style location (able to use directory outside of phpBB). - * - * Note: Templates are still compiled to phpBB's cache directory. - * - * @param string $name Name of style, used for cache prefix. Examples: "admin", "prosilver" - * @param array or string $paths Array of style paths, relative to current root directory - * @param array $names Array of names of templates in inheritance tree order, used by extensions. If empty, $name will be used. - * @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/). - * @return bool true - */ - public function set_custom_style($name, $paths, $names = array(), $template_path = false) - { - if (is_string($paths)) - { - $paths = array($paths); - } - - if (empty($names)) - { - $names = array($name); - } - $this->names = $names; - - $new_paths = array(); - foreach ($paths as $path) - { - $new_paths[] = $path . '/' . (($template_path !== false) ? $template_path : 'template/'); - } - - $this->template->set_style_names($names, $new_paths); - - return true; - } - - /** - * Get location of style directory for specific style_path - * - * @param string $path Style path, such as "prosilver" - * @param string $style_base_directory The base directory the style is in - * E.g. 'styles', 'ext/foo/bar/styles' - * Default: 'styles' - * @return string Path to style directory, relative to current path - */ - public function get_style_path($path, $style_base_directory = 'styles') - { - return $this->phpbb_root_path . trim($style_base_directory, '/') . '/' . $path; - } -} diff --git a/phpBB/phpbb/template/template.php b/phpBB/phpbb/template/template.php index 89a01e924d..537c4eaf01 100644 --- a/phpBB/phpbb/template/template.php +++ b/phpBB/phpbb/template/template.php @@ -33,6 +33,36 @@ interface phpbb_template */ public function set_filenames(array $filename_array); + /** + * Get the style tree of the style preferred by the current user + * + * @return array Style tree, most specific first + */ + public function get_user_style(); + + /** + * Set style location based on (current) user's chosen style. + * + * @param array $style_directories The directories to add style paths for + * E.g. array('ext/foo/bar/styles', 'styles') + * Default: array('styles') (phpBB's style directory) + * @return bool true + */ + public function set_style($style_directories = array('styles')); + + /** + * Set custom style location (able to use directory outside of phpBB). + * + * Note: Templates are still compiled to phpBB's cache directory. + * + * @param string $name Name of style, used for cache prefix. Examples: "admin", "prosilver" + * @param array or string $paths Array of style paths, relative to current root directory + * @param array $names Array of names of templates in inheritance tree order, used by extensions. If empty, $name will be used. + * @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/). + * @return bool true + */ + public function set_custom_style($name, $paths, $names = array(), $template_path = false); + /** * Sets the style names/paths corresponding to style hierarchy being compiled * and/or rendered. diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 92a37d1634..92a52d26b8 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -177,6 +177,97 @@ class phpbb_template_twig implements phpbb_template return $this; } + /** + * Get the style tree of the style preferred by the current user + * + * @return array Style tree, most specific first + */ + public function get_user_style() + { + $style_list = array( + $this->user->style['style_path'], + ); + + if ($this->user->style['style_parent_id']) + { + $style_list = array_merge($style_list, array_reverse(explode('/', $this->user->style['style_parent_tree']))); + } + + return $style_list; + } + + /** + * Set style location based on (current) user's chosen style. + * + * @param array $style_directories The directories to add style paths for + * E.g. array('ext/foo/bar/styles', 'styles') + * Default: array('styles') (phpBB's style directory) + * @return bool true + */ + public function set_style($style_directories = array('styles')) + { + $this->names = $this->get_user_style(); + + $paths = array(); + foreach ($style_directories as $directory) + { + foreach ($this->names as $name) + { + $path = $this->get_style_path($name, $directory); + + if (is_dir($path)) + { + $paths[] = $path; + } + } + } + + $new_paths = array(); + foreach ($paths as $path) + { + $new_paths[] = $path . '/template/'; + } + + $this->set_style_names($this->names, $new_paths, ($style_directories === array('styles'))); + + return true; + } + + /** + * Set custom style location (able to use directory outside of phpBB). + * + * Note: Templates are still compiled to phpBB's cache directory. + * + * @param string $name Name of style, used for cache prefix. Examples: "admin", "prosilver" + * @param array or string $paths Array of style paths, relative to current root directory + * @param array $names Array of names of templates in inheritance tree order, used by extensions. If empty, $name will be used. + * @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/). + * @return bool true + */ + public function set_custom_style($name, $paths, $names = array(), $template_path = false) + { + if (is_string($paths)) + { + $paths = array($paths); + } + + if (empty($names)) + { + $names = array($name); + } + $this->names = $names; + + $new_paths = array(); + foreach ($paths as $path) + { + $new_paths[] = $path . '/' . (($template_path !== false) ? $template_path : 'template/'); + } + + $this->set_style_names($names, $new_paths); + + return true; + } + /** * Sets the style names/paths corresponding to style hierarchy being compiled * and/or rendered. @@ -194,7 +285,7 @@ class phpbb_template_twig implements phpbb_template // Set as __main__ namespace $this->twig->getLoader()->setPaths($style_paths); - // Core style namespace from phpbb_style::set_style() + // Core style namespace from this::set_style() if ($is_core) { $this->twig->getLoader()->setPaths($style_paths, 'core'); @@ -462,4 +553,18 @@ class phpbb_template_twig implements phpbb_template { return $this->twig->getLoader()->getCacheKey($this->get_filename_from_handle($handle)); } + + /** + * Get location of style directory for specific style_path + * + * @param string $path Style path, such as "prosilver" + * @param string $style_base_directory The base directory the style is in + * E.g. 'styles', 'ext/foo/bar/styles' + * Default: 'styles' + * @return string Path to style directory, relative to current path + */ + protected function get_style_path($path, $style_base_directory = 'styles') + { + return $this->phpbb_root_path . trim($style_base_directory, '/') . '/' . $path; + } } diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php index 5530fe3f03..2828bab6a8 100644 --- a/phpBB/phpbb/user.php +++ b/phpBB/phpbb/user.php @@ -75,7 +75,7 @@ class phpbb_user extends phpbb_session */ function setup($lang_set = false, $style_id = false) { - global $db, $phpbb_style, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache; + global $db, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache; global $phpbb_dispatcher; if ($this->data['user_id'] != ANONYMOUS) @@ -236,7 +236,7 @@ class phpbb_user extends phpbb_session } } - $phpbb_style->set_style(); + $template->set_style(); $this->img_lang = $this->lang_name; -- cgit v1.2.1 From 85ff05bec635e8e6ef0fb64a561e2dd400b53897 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 12:34:22 -0500 Subject: [ticket/11628] Remove $this->names, $this->style_names from phpbb_template These are not used anywhere PHPBB3-11628 --- phpBB/phpbb/template/twig/twig.php | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 92a52d26b8..4ae918ed86 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -74,16 +74,6 @@ class phpbb_template_twig implements phpbb_template */ protected $extension_manager; - /** - * Name of the style that the template being compiled and/or rendered - * belongs to, and its parents, in inheritance tree order. - * - * Used to invoke style-specific template events. - * - * @var array - */ - protected $style_names; - /** * Twig Environment * @@ -206,12 +196,12 @@ class phpbb_template_twig implements phpbb_template */ public function set_style($style_directories = array('styles')) { - $this->names = $this->get_user_style(); + $names = $this->get_user_style(); $paths = array(); foreach ($style_directories as $directory) { - foreach ($this->names as $name) + foreach ($names as $name) { $path = $this->get_style_path($name, $directory); @@ -228,7 +218,7 @@ class phpbb_template_twig implements phpbb_template $new_paths[] = $path . '/template/'; } - $this->set_style_names($this->names, $new_paths, ($style_directories === array('styles'))); + $this->set_style_names($names, $new_paths, ($style_directories === array('styles'))); return true; } @@ -255,7 +245,6 @@ class phpbb_template_twig implements phpbb_template { $names = array($name); } - $this->names = $names; $new_paths = array(); foreach ($paths as $path) @@ -280,8 +269,6 @@ class phpbb_template_twig implements phpbb_template */ public function set_style_names(array $style_names, array $style_paths, $is_core = false) { - $this->style_names = $style_names; - // Set as __main__ namespace $this->twig->getLoader()->setPaths($style_paths); -- cgit v1.2.1 From ecaed319ab46ee4dd45fe788a05aaeff96afc1d2 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 12:42:37 -0500 Subject: [ticket/11628] Move setting core namespace to set_style() PHPBB3-11628 --- phpBB/phpbb/template/twig/twig.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 4ae918ed86..eb84da20dc 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -196,6 +196,12 @@ class phpbb_template_twig implements phpbb_template */ public function set_style($style_directories = array('styles')) { + if ($style_directories !== array('styles') && $this->twig->getLoader()->getPaths('core') === array()) + { + // We should set up the core styles path since not already setup + $this->set_style(); + } + $names = $this->get_user_style(); $paths = array(); @@ -203,7 +209,7 @@ class phpbb_template_twig implements phpbb_template { foreach ($names as $name) { - $path = $this->get_style_path($name, $directory); + $path = $this->get_style_path($name, $directory) . 'template/'; if (is_dir($path)) { @@ -212,13 +218,15 @@ class phpbb_template_twig implements phpbb_template } } - $new_paths = array(); - foreach ($paths as $path) + // If we're setting up the main phpBB styles directory and the core + // namespace isn't setup yet, we will set it up now + if ($style_directories === array('styles') && $this->twig->getLoader()->getPaths('core') === array()) { - $new_paths[] = $path . '/template/'; + // Set up the core style paths namespace + $this->twig->getLoader()->setPaths($paths, 'core'); } - $this->set_style_names($names, $new_paths, ($style_directories === array('styles'))); + $this->set_style_names($names, $paths); return true; } @@ -263,21 +271,13 @@ class phpbb_template_twig implements phpbb_template * * @param array $style_names List of style names in inheritance tree order * @param array $style_paths List of style paths in inheritance tree order - * @param bool $is_core True if the style names are the "core" styles for this page load - * Core means the main phpBB template files * @return phpbb_template $this */ - public function set_style_names(array $style_names, array $style_paths, $is_core = false) + public function set_style_names(array $style_names, array $style_paths) { // Set as __main__ namespace $this->twig->getLoader()->setPaths($style_paths); - // Core style namespace from this::set_style() - if ($is_core) - { - $this->twig->getLoader()->setPaths($style_paths, 'core'); - } - // Add admin namespace if (is_dir($this->phpbb_root_path . $this->adm_relative_path . 'style/')) { @@ -552,6 +552,6 @@ class phpbb_template_twig implements phpbb_template */ protected function get_style_path($path, $style_base_directory = 'styles') { - return $this->phpbb_root_path . trim($style_base_directory, '/') . '/' . $path; + return $this->phpbb_root_path . trim($style_base_directory, '/') . '/' . rtrim($path, '/') . '/'; } } -- cgit v1.2.1 From bfbc7aa74250ea5e9e39efc63caf7cfdb9407e14 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 12:45:35 -0500 Subject: [ticket/11628] Return $this from set_style, set_custom_style PHPBB3-11628 --- phpBB/phpbb/template/template.php | 4 ++-- phpBB/phpbb/template/twig/twig.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/template/template.php b/phpBB/phpbb/template/template.php index 537c4eaf01..95a48ba0ad 100644 --- a/phpBB/phpbb/template/template.php +++ b/phpBB/phpbb/template/template.php @@ -46,7 +46,7 @@ interface phpbb_template * @param array $style_directories The directories to add style paths for * E.g. array('ext/foo/bar/styles', 'styles') * Default: array('styles') (phpBB's style directory) - * @return bool true + * @return phpbb_template $this */ public function set_style($style_directories = array('styles')); @@ -59,7 +59,7 @@ interface phpbb_template * @param array or string $paths Array of style paths, relative to current root directory * @param array $names Array of names of templates in inheritance tree order, used by extensions. If empty, $name will be used. * @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/). - * @return bool true + * @return phpbb_template $this */ public function set_custom_style($name, $paths, $names = array(), $template_path = false); diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index eb84da20dc..48ea8edeb1 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -192,7 +192,7 @@ class phpbb_template_twig implements phpbb_template * @param array $style_directories The directories to add style paths for * E.g. array('ext/foo/bar/styles', 'styles') * Default: array('styles') (phpBB's style directory) - * @return bool true + * @return phpbb_template $this */ public function set_style($style_directories = array('styles')) { @@ -228,7 +228,7 @@ class phpbb_template_twig implements phpbb_template $this->set_style_names($names, $paths); - return true; + return $this; } /** @@ -240,7 +240,7 @@ class phpbb_template_twig implements phpbb_template * @param array or string $paths Array of style paths, relative to current root directory * @param array $names Array of names of templates in inheritance tree order, used by extensions. If empty, $name will be used. * @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/). - * @return bool true + * @return phpbb_template $this */ public function set_custom_style($name, $paths, $names = array(), $template_path = false) { @@ -262,7 +262,7 @@ class phpbb_template_twig implements phpbb_template $this->set_style_names($names, $new_paths); - return true; + return $this; } /** -- cgit v1.2.1 From 581cb37b8c7ae4f1902cfd6114a34ce1510139a8 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 24 Jul 2013 13:46:33 -0400 Subject: [feature/oauth] Start linking/registering OAuth accounts during login PHPBB3-11673 --- phpBB/includes/constants.php | 1 + phpBB/phpbb/auth/auth.php | 15 +++++++++++++++ phpBB/phpbb/auth/provider/interface.php | 5 +++++ phpBB/phpbb/auth/provider/oauth/oauth.php | 10 +++++++++- 4 files changed, 30 insertions(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index c1f4c6ac0e..ae55a71e50 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -61,6 +61,7 @@ define('LOGIN_CONTINUE', 1); define('LOGIN_BREAK', 2); define('LOGIN_SUCCESS', 3); define('LOGIN_SUCCESS_CREATE_PROFILE', 20); +define('LOGIN_SUCCESS_LINK_PROFILE', 21); define('LOGIN_ERROR_USERNAME', 10); define('LOGIN_ERROR_PASSWORD', 11); define('LOGIN_ERROR_ACTIVE', 12); diff --git a/phpBB/phpbb/auth/auth.php b/phpBB/phpbb/auth/auth.php index 279959974d..400f5fef6d 100644 --- a/phpBB/phpbb/auth/auth.php +++ b/phpBB/phpbb/auth/auth.php @@ -970,6 +970,21 @@ class phpbb_auth ); } + // If the auth provider wants us to link an empty account do so and redirect + if ($login['status'] == LOGIN_SUCCESS_LINK_PROFILE) + { + // If this status exists a fourth field is in the $login array called 'redirect_data' + // This data is passed along as GET data to the next page allow the account to be linked + $url = 'ucp.php?mode=login_link'; + + foreach ($login['redirect_data'] as $key => $value) + { + $url .= '&' . $key . '=' . $value; + } + + redirect($url); + } + // If login succeeded, we will log the user in... else we pass the login array through... if ($login['status'] == LOGIN_SUCCESS) { diff --git a/phpBB/phpbb/auth/provider/interface.php b/phpBB/phpbb/auth/provider/interface.php index f4344c1dc7..9cee63abeb 100644 --- a/phpBB/phpbb/auth/provider/interface.php +++ b/phpBB/phpbb/auth/provider/interface.php @@ -45,6 +45,11 @@ interface phpbb_auth_provider_interface * 'error_msg' => string * 'user_row' => array * ) + * A fourth key of the array may be present 'redirect_data' + * This key is only used when 'status' is equal to + * LOGIN_SUCCESS_LINK_PROFILE and it's value is an + * associative array that is turned into GET variables on + * the redirect url. */ public function login($username, $password); diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 90ce1f8f5a..5fc940fade 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -172,7 +172,15 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base if (!$row) { // The user does not yet exist, ask if they wish to register the account - throw new Exception($unique_id); + return array( + 'status' => LOGIN_SUCCESS_LINK_PROFILE, + 'error_msg' => 'LOGIN_OAUTH_ACCOUNT_NOT_LINKED', + 'user_row' => array(), + 'redirect_data' => array( + 'auth_provider' => 'oauth', + 'oauth_service' => $service_name_original, + ), + ); } // Retrieve the user's account -- cgit v1.2.1 From 4b761f65758c40db4851983fa3a08d354da3323d Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 12:55:41 -0500 Subject: [ticket/11628] Remove third parameter ($names) from set_custom_style This was basically duplicating functionality. $names would be used if not empty, else array($name) would be used. Merged functionality into the first argument PHPBB3-11628 --- phpBB/adm/index.php | 2 +- phpBB/adm/swatch.php | 2 +- phpBB/includes/functions_module.php | 2 +- phpBB/install/index.php | 2 +- phpBB/install/install_update.php | 2 +- phpBB/phpbb/template/template.php | 5 ++--- phpBB/phpbb/template/twig/twig.php | 9 ++++----- 7 files changed, 11 insertions(+), 13 deletions(-) (limited to 'phpBB') diff --git a/phpBB/adm/index.php b/phpBB/adm/index.php index 3f29072899..c79327d22c 100644 --- a/phpBB/adm/index.php +++ b/phpBB/adm/index.php @@ -50,7 +50,7 @@ $module_id = request_var('i', ''); $mode = request_var('mode', ''); // Set custom style for admin area -$template->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); +$template->set_custom_style('admin', $phpbb_admin_path . 'style', ''); $template->assign_var('T_ASSETS_PATH', $phpbb_root_path . 'assets'); $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style'); diff --git a/phpBB/adm/swatch.php b/phpBB/adm/swatch.php index 70441ffeed..ef89081dc8 100644 --- a/phpBB/adm/swatch.php +++ b/phpBB/adm/swatch.php @@ -22,7 +22,7 @@ $auth->acl($user->data); $user->setup(); // Set custom template for admin area -$template->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); +$template->set_custom_style('admin', $phpbb_admin_path . 'style', ''); $template->set_filenames(array( 'body' => 'colour_swatch.html') diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index a5ece1ecac..c84e02afe6 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -508,7 +508,7 @@ class p_master if (is_dir($module_style_dir)) { - $template->set_custom_style('admin', array($module_style_dir, $phpbb_admin_path . 'style'), array(), ''); + $template->set_custom_style('admin', array($module_style_dir, $phpbb_admin_path . 'style'), ''); } } diff --git a/phpBB/install/index.php b/phpBB/install/index.php index fd0d8a2d48..f80b975e2c 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -213,7 +213,7 @@ $config = new phpbb_config(array( )); $template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context()); -$template->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); +$template->set_custom_style('admin', $phpbb_admin_path . 'style', ''); $template->assign_var('T_ASSETS_PATH', '../assets'); $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style'); diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 51fbd1975c..63f10c96d7 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -138,7 +138,7 @@ class install_update extends module } // Set custom template again. ;) - $template->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); + $template->set_custom_style('admin', $phpbb_admin_path . 'style', ''); $template->assign_vars(array( 'S_USER_LANG' => $user->lang['USER_LANG'], diff --git a/phpBB/phpbb/template/template.php b/phpBB/phpbb/template/template.php index 95a48ba0ad..c77586587f 100644 --- a/phpBB/phpbb/template/template.php +++ b/phpBB/phpbb/template/template.php @@ -55,13 +55,12 @@ interface phpbb_template * * Note: Templates are still compiled to phpBB's cache directory. * - * @param string $name Name of style, used for cache prefix. Examples: "admin", "prosilver" + * @param string|array $names Array of names or string of name of template(s) in inheritance tree order, used by extensions. * @param array or string $paths Array of style paths, relative to current root directory - * @param array $names Array of names of templates in inheritance tree order, used by extensions. If empty, $name will be used. * @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/). * @return phpbb_template $this */ - public function set_custom_style($name, $paths, $names = array(), $template_path = false); + public function set_custom_style($names, $paths, $template_path = false); /** * Sets the style names/paths corresponding to style hierarchy being compiled diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 48ea8edeb1..c9249196e7 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -236,22 +236,21 @@ class phpbb_template_twig implements phpbb_template * * Note: Templates are still compiled to phpBB's cache directory. * - * @param string $name Name of style, used for cache prefix. Examples: "admin", "prosilver" + * @param string|array $names Array of names or string of name of template(s) in inheritance tree order, used by extensions. * @param array or string $paths Array of style paths, relative to current root directory - * @param array $names Array of names of templates in inheritance tree order, used by extensions. If empty, $name will be used. * @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/). * @return phpbb_template $this */ - public function set_custom_style($name, $paths, $names = array(), $template_path = false) + public function set_custom_style($names, $paths, $template_path = false) { if (is_string($paths)) { $paths = array($paths); } - if (empty($names)) + if (!is_array($names)) { - $names = array($name); + $names = array($names); } $new_paths = array(); -- cgit v1.2.1 From 67627f3336f7a90a7de67427d25c8cdd43d74f6e Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 13:01:30 -0500 Subject: [ticket/11628] Change set_custom_style $template path to default to string Rather than default to false and compare === false ? 'template/' : value just assign this default in the arguments PHPBB3-11628 --- phpBB/phpbb/template/template.php | 4 ++-- phpBB/phpbb/template/twig/twig.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/template/template.php b/phpBB/phpbb/template/template.php index c77586587f..c929934376 100644 --- a/phpBB/phpbb/template/template.php +++ b/phpBB/phpbb/template/template.php @@ -57,10 +57,10 @@ interface phpbb_template * * @param string|array $names Array of names or string of name of template(s) in inheritance tree order, used by extensions. * @param array or string $paths Array of style paths, relative to current root directory - * @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/). + * @param string $template_path Path to templates, relative to style directory. Default (template/). * @return phpbb_template $this */ - public function set_custom_style($names, $paths, $template_path = false); + public function set_custom_style($names, $paths, $template_path = 'template/'); /** * Sets the style names/paths corresponding to style hierarchy being compiled diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index c9249196e7..5537b1195c 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -238,10 +238,10 @@ class phpbb_template_twig implements phpbb_template * * @param string|array $names Array of names or string of name of template(s) in inheritance tree order, used by extensions. * @param array or string $paths Array of style paths, relative to current root directory - * @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/). + * @param string $template_path Path to templates, relative to style directory. Default (template/). * @return phpbb_template $this */ - public function set_custom_style($names, $paths, $template_path = false) + public function set_custom_style($names, $paths, $template_path = 'template/') { if (is_string($paths)) { @@ -256,7 +256,7 @@ class phpbb_template_twig implements phpbb_template $new_paths = array(); foreach ($paths as $path) { - $new_paths[] = $path . '/' . (($template_path !== false) ? $template_path : 'template/'); + $new_paths[] = $path . '/' . ltrim($template_path, '/'); } $this->set_style_names($names, $new_paths); -- cgit v1.2.1 From 44142782095f4a847e575dde40faef867c704220 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 13:04:27 -0500 Subject: [ticket/11628] Set admin namespace in the constructor PHPBB3-11628 --- phpBB/phpbb/template/twig/twig.php | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 5537b1195c..72ba70ecc4 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -43,12 +43,6 @@ class phpbb_template_twig implements phpbb_template */ protected $phpbb_root_path; - /** - * adm relative path - * @var string - */ - protected $adm_relative_path; - /** * PHP file extension * @var string @@ -102,7 +96,6 @@ class phpbb_template_twig implements phpbb_template public function __construct($phpbb_root_path, $php_ext, $config, $user, phpbb_template_context $context, phpbb_extension_manager $extension_manager = null, $adm_relative_path = null) { $this->phpbb_root_path = $phpbb_root_path; - $this->adm_relative_path = $adm_relative_path; $this->php_ext = $php_ext; $this->config = $config; $this->user = $user; @@ -137,6 +130,12 @@ class phpbb_template_twig implements phpbb_template $lexer = new phpbb_template_twig_lexer($this->twig); $this->twig->setLexer($lexer); + + // Add admin namespace + if ($adm_relative_path !== null && is_dir($this->phpbb_root_path . $adm_relative_path . 'style/')) + { + $this->twig->getLoader()->setPaths($this->phpbb_root_path . $adm_relative_path . 'style/', 'admin'); + } } /** @@ -277,12 +276,6 @@ class phpbb_template_twig implements phpbb_template // Set as __main__ namespace $this->twig->getLoader()->setPaths($style_paths); - // Add admin namespace - if (is_dir($this->phpbb_root_path . $this->adm_relative_path . 'style/')) - { - $this->twig->getLoader()->setPaths($this->phpbb_root_path . $this->adm_relative_path . 'style/', 'admin'); - } - // Add all namespaces for all extensions if ($this->extension_manager instanceof phpbb_extension_manager) { -- cgit v1.2.1 From 5843294813fc654a37e13e9da357e7515a41968a Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 24 Jul 2013 14:05:39 -0400 Subject: [feature/oauth] Update comment to better reflect the action PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 5fc940fade..a8b55fc532 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -171,7 +171,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base if (!$row) { - // The user does not yet exist, ask if they wish to register the account + // The user does not yet exist, ask to link or create profile return array( 'status' => LOGIN_SUCCESS_LINK_PROFILE, 'error_msg' => 'LOGIN_OAUTH_ACCOUNT_NOT_LINKED', -- cgit v1.2.1 From 863592a8bedbacf3e7bf6bee458797e819020e6f Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 13:19:20 -0500 Subject: [ticket/11628] Remove set_style_names function, moved to set_custom_style PHPBB3-11628 --- phpBB/includes/functions_messenger.php | 2 +- phpBB/phpbb/template/template.php | 10 ---------- phpBB/phpbb/template/twig/twig.php | 27 ++++++--------------------- 3 files changed, 7 insertions(+), 32 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 0222a57bcc..89dd3c70fc 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -660,7 +660,7 @@ class messenger { $this->setup_template(); - $this->template->set_style_names(array($path_name), $paths); + $this->template->set_custom_style($path_name, $paths, ''); } } diff --git a/phpBB/phpbb/template/template.php b/phpBB/phpbb/template/template.php index c929934376..8554365c95 100644 --- a/phpBB/phpbb/template/template.php +++ b/phpBB/phpbb/template/template.php @@ -62,16 +62,6 @@ interface phpbb_template */ public function set_custom_style($names, $paths, $template_path = 'template/'); - /** - * Sets the style names/paths corresponding to style hierarchy being compiled - * and/or rendered. - * - * @param array $style_names List of style names in inheritance tree order - * @param array $style_paths List of style paths in inheritance tree order - * @return phpbb_template $this - */ - public function set_style_names(array $style_names, array $style_paths); - /** * Clears all variables and blocks assigned to this template. * diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 72ba70ecc4..26f454e972 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -225,7 +225,7 @@ class phpbb_template_twig implements phpbb_template $this->twig->getLoader()->setPaths($paths, 'core'); } - $this->set_style_names($names, $paths); + $this->set_custom_style($names, $paths, ''); return $this; } @@ -247,39 +247,24 @@ class phpbb_template_twig implements phpbb_template $paths = array($paths); } - if (!is_array($names)) + if (is_string($names)) { $names = array($names); } - $new_paths = array(); + $style_paths = array(); foreach ($paths as $path) { - $new_paths[] = $path . '/' . ltrim($template_path, '/'); + $style_paths[] = $path . '/' . ltrim($template_path, '/'); } - $this->set_style_names($names, $new_paths); - - return $this; - } - - /** - * Sets the style names/paths corresponding to style hierarchy being compiled - * and/or rendered. - * - * @param array $style_names List of style names in inheritance tree order - * @param array $style_paths List of style paths in inheritance tree order - * @return phpbb_template $this - */ - public function set_style_names(array $style_names, array $style_paths) - { // Set as __main__ namespace $this->twig->getLoader()->setPaths($style_paths); // Add all namespaces for all extensions if ($this->extension_manager instanceof phpbb_extension_manager) { - $style_names[] = 'all'; + $names[] = 'all'; foreach ($this->extension_manager->all_enabled() as $ext_namespace => $ext_path) { @@ -287,7 +272,7 @@ class phpbb_template_twig implements phpbb_template $namespace = str_replace('/', '_', $ext_namespace); $paths = array(); - foreach ($style_names as $style_name) + foreach ($names as $style_name) { $ext_style_path = $ext_path . 'styles/' . $style_name . '/template'; -- cgit v1.2.1 From 12c22585069066957cc3211136ebd480295d4758 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 13:25:20 -0500 Subject: [ticket/11628] Remove template_path option on set_custom_style This was set to default 'template/' to append template/ to all the paths, but every location was actually just setting it to '' to not append anything. So removed the option entirely (additional paths can be appended to the paths being sent to the function already) PHPBB3-11628 --- phpBB/adm/index.php | 2 +- phpBB/adm/swatch.php | 2 +- phpBB/includes/functions_messenger.php | 2 +- phpBB/includes/functions_module.php | 2 +- phpBB/install/index.php | 2 +- phpBB/install/install_update.php | 2 +- phpBB/phpbb/template/template.php | 3 +-- phpBB/phpbb/template/twig/twig.php | 13 +++---------- 8 files changed, 10 insertions(+), 18 deletions(-) (limited to 'phpBB') diff --git a/phpBB/adm/index.php b/phpBB/adm/index.php index c79327d22c..3520eb8b70 100644 --- a/phpBB/adm/index.php +++ b/phpBB/adm/index.php @@ -50,7 +50,7 @@ $module_id = request_var('i', ''); $mode = request_var('mode', ''); // Set custom style for admin area -$template->set_custom_style('admin', $phpbb_admin_path . 'style', ''); +$template->set_custom_style('admin', $phpbb_admin_path . 'style'); $template->assign_var('T_ASSETS_PATH', $phpbb_root_path . 'assets'); $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style'); diff --git a/phpBB/adm/swatch.php b/phpBB/adm/swatch.php index ef89081dc8..cdd6bf3969 100644 --- a/phpBB/adm/swatch.php +++ b/phpBB/adm/swatch.php @@ -22,7 +22,7 @@ $auth->acl($user->data); $user->setup(); // Set custom template for admin area -$template->set_custom_style('admin', $phpbb_admin_path . 'style', ''); +$template->set_custom_style('admin', $phpbb_admin_path . 'style'); $template->set_filenames(array( 'body' => 'colour_swatch.html') diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 89dd3c70fc..3a9e1fa77b 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -660,7 +660,7 @@ class messenger { $this->setup_template(); - $this->template->set_custom_style($path_name, $paths, ''); + $this->template->set_custom_style($path_name, $paths); } } diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index c84e02afe6..8f0f6a837a 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -508,7 +508,7 @@ class p_master if (is_dir($module_style_dir)) { - $template->set_custom_style('admin', array($module_style_dir, $phpbb_admin_path . 'style'), ''); + $template->set_custom_style('admin', array($module_style_dir, $phpbb_admin_path . 'style')); } } diff --git a/phpBB/install/index.php b/phpBB/install/index.php index f80b975e2c..84d751e279 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -213,7 +213,7 @@ $config = new phpbb_config(array( )); $template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context()); -$template->set_custom_style('admin', $phpbb_admin_path . 'style', ''); +$template->set_custom_style('admin', $phpbb_admin_path . 'style'); $template->assign_var('T_ASSETS_PATH', '../assets'); $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style'); diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 63f10c96d7..a105944fb3 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -138,7 +138,7 @@ class install_update extends module } // Set custom template again. ;) - $template->set_custom_style('admin', $phpbb_admin_path . 'style', ''); + $template->set_custom_style('admin', $phpbb_admin_path . 'style'); $template->assign_vars(array( 'S_USER_LANG' => $user->lang['USER_LANG'], diff --git a/phpBB/phpbb/template/template.php b/phpBB/phpbb/template/template.php index 8554365c95..9881938a8f 100644 --- a/phpBB/phpbb/template/template.php +++ b/phpBB/phpbb/template/template.php @@ -57,10 +57,9 @@ interface phpbb_template * * @param string|array $names Array of names or string of name of template(s) in inheritance tree order, used by extensions. * @param array or string $paths Array of style paths, relative to current root directory - * @param string $template_path Path to templates, relative to style directory. Default (template/). * @return phpbb_template $this */ - public function set_custom_style($names, $paths, $template_path = 'template/'); + public function set_custom_style($names, $paths); /** * Clears all variables and blocks assigned to this template. diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 26f454e972..4aa1774ef4 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -225,7 +225,7 @@ class phpbb_template_twig implements phpbb_template $this->twig->getLoader()->setPaths($paths, 'core'); } - $this->set_custom_style($names, $paths, ''); + $this->set_custom_style($names, $paths); return $this; } @@ -237,10 +237,9 @@ class phpbb_template_twig implements phpbb_template * * @param string|array $names Array of names or string of name of template(s) in inheritance tree order, used by extensions. * @param array or string $paths Array of style paths, relative to current root directory - * @param string $template_path Path to templates, relative to style directory. Default (template/). * @return phpbb_template $this */ - public function set_custom_style($names, $paths, $template_path = 'template/') + public function set_custom_style($names, $paths) { if (is_string($paths)) { @@ -252,14 +251,8 @@ class phpbb_template_twig implements phpbb_template $names = array($names); } - $style_paths = array(); - foreach ($paths as $path) - { - $style_paths[] = $path . '/' . ltrim($template_path, '/'); - } - // Set as __main__ namespace - $this->twig->getLoader()->setPaths($style_paths); + $this->twig->getLoader()->setPaths($paths); // Add all namespaces for all extensions if ($this->extension_manager instanceof phpbb_extension_manager) -- cgit v1.2.1 From 3b46f77e4e77defdd7c38249c865fdaecd83629e Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 13:26:55 -0500 Subject: [ticket/11628] Shorten an if to an inline statement PHPBB3-11628 --- phpBB/phpbb/template/twig/twig.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 4aa1774ef4..c3ed52c3bd 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -241,15 +241,8 @@ class phpbb_template_twig implements phpbb_template */ public function set_custom_style($names, $paths) { - if (is_string($paths)) - { - $paths = array($paths); - } - - if (is_string($names)) - { - $names = array($names); - } + $paths = (is_string($paths)) ? array($paths) : $paths; + $names = (is_string($names)) ? array($names) : $names; // Set as __main__ namespace $this->twig->getLoader()->setPaths($paths); -- cgit v1.2.1 From 8795a354fed4e78b64cce531e6deaec9aa4d56f8 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 13:31:09 -0500 Subject: [ticket/11628] Remove the one usage of get_style_path() Makes the code easier to follow PHPBB3-11628 --- phpBB/phpbb/template/template.php | 2 +- phpBB/phpbb/template/twig/twig.php | 18 ++---------------- 2 files changed, 3 insertions(+), 17 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/template/template.php b/phpBB/phpbb/template/template.php index 9881938a8f..6b9c331a3e 100644 --- a/phpBB/phpbb/template/template.php +++ b/phpBB/phpbb/template/template.php @@ -56,7 +56,7 @@ interface phpbb_template * Note: Templates are still compiled to phpBB's cache directory. * * @param string|array $names Array of names or string of name of template(s) in inheritance tree order, used by extensions. - * @param array or string $paths Array of style paths, relative to current root directory + * @param string|array or string $paths Array of style paths, relative to current root directory * @return phpbb_template $this */ public function set_custom_style($names, $paths); diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index c3ed52c3bd..0b5b4105ae 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -208,7 +208,7 @@ class phpbb_template_twig implements phpbb_template { foreach ($names as $name) { - $path = $this->get_style_path($name, $directory) . 'template/'; + $path = $this->phpbb_root_path . trim($directory, '/') . "/{$name}/template/"; if (is_dir($path)) { @@ -236,7 +236,7 @@ class phpbb_template_twig implements phpbb_template * Note: Templates are still compiled to phpBB's cache directory. * * @param string|array $names Array of names or string of name of template(s) in inheritance tree order, used by extensions. - * @param array or string $paths Array of style paths, relative to current root directory + * @param string|array or string $paths Array of style paths, relative to current root directory * @return phpbb_template $this */ public function set_custom_style($names, $paths) @@ -503,18 +503,4 @@ class phpbb_template_twig implements phpbb_template { return $this->twig->getLoader()->getCacheKey($this->get_filename_from_handle($handle)); } - - /** - * Get location of style directory for specific style_path - * - * @param string $path Style path, such as "prosilver" - * @param string $style_base_directory The base directory the style is in - * E.g. 'styles', 'ext/foo/bar/styles' - * Default: 'styles' - * @return string Path to style directory, relative to current path - */ - protected function get_style_path($path, $style_base_directory = 'styles') - { - return $this->phpbb_root_path . trim($style_base_directory, '/') . '/' . rtrim($path, '/') . '/'; - } } -- cgit v1.2.1 From 427fa17f7fd9db6f69a6cb4634198a2f484e0bd9 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 13:34:41 -0500 Subject: [ticket/11628] Fix a bug I noticed in template->destroy Should not be setting $this->context = array()! PHPBB3-11628 --- phpBB/phpbb/template/twig/twig.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 0b5b4105ae..710411c594 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -282,7 +282,7 @@ class phpbb_template_twig implements phpbb_template */ public function destroy() { - $this->context = array(); + $this->context->clear(); return $this; } -- cgit v1.2.1 From ffbc144a739740ad1901c9eaf481815c9ec2d918 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 13:38:12 -0500 Subject: [ticket/11628] Make get_template_vars protected Remove all references to it and the hacky code in messenger that was using it PHPBB3-11628 --- phpBB/includes/functions_messenger.php | 31 +++++++------------------------ phpBB/phpbb/template/twig/twig.php | 2 +- 2 files changed, 8 insertions(+), 25 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 3a9e1fa77b..3bfc1a44f0 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -21,7 +21,7 @@ if (!defined('IN_PHPBB')) */ class messenger { - var $vars, $msg, $extra_headers, $replyto, $from, $subject; + var $msg, $extra_headers, $replyto, $from, $subject; var $addresses = array(); var $mail_priority = MAIL_NORMAL_PRIORITY; @@ -53,7 +53,7 @@ class messenger function reset() { $this->addresses = $this->extra_headers = array(); - $this->vars = $this->msg = $this->replyto = $this->from = ''; + $this->msg = $this->replyto = $this->from = ''; $this->mail_priority = MAIL_NORMAL_PRIORITY; } @@ -258,8 +258,6 @@ class messenger 'body' => $template_file . '.txt', )); - $this->vars = $this->template->get_template_vars(); - return true; } @@ -288,26 +286,11 @@ class messenger global $config, $user; // We add some standard variables we always use, no need to specify them always - if (!isset($this->vars['U_BOARD'])) - { - $this->assign_vars(array( - 'U_BOARD' => generate_board_url(), - )); - } - - if (!isset($this->vars['EMAIL_SIG'])) - { - $this->assign_vars(array( - 'EMAIL_SIG' => str_replace('
', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])), - )); - } - - if (!isset($this->vars['SITENAME'])) - { - $this->assign_vars(array( - 'SITENAME' => htmlspecialchars_decode($config['sitename']), - )); - } + $this->assign_vars(array( + 'U_BOARD' => generate_board_url(), + 'EMAIL_SIG' => str_replace('
', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])), + 'SITENAME' => htmlspecialchars_decode($config['sitename']), + )); // Parse message through template $this->msg = trim($this->template->assign_display('body')); diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 710411c594..582939c252 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -464,7 +464,7 @@ class phpbb_template_twig implements phpbb_template * * @return array */ - public function get_template_vars() + protected function get_template_vars() { $context_vars = $this->context->get_data_ref(); -- cgit v1.2.1 From 27ea03d3e098ca53f9f49da5024f7d7c64989153 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 24 Jul 2013 14:55:08 -0400 Subject: [feature/oauth] Initial login_link ucp class PHPBB3-11673 --- phpBB/includes/ucp/ucp_login_link.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 phpBB/includes/ucp/ucp_login_link.php (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_login_link.php b/phpBB/includes/ucp/ucp_login_link.php new file mode 100644 index 0000000000..719dec5ea0 --- /dev/null +++ b/phpBB/includes/ucp/ucp_login_link.php @@ -0,0 +1,32 @@ + Date: Wed, 24 Jul 2013 15:06:38 -0400 Subject: [feature/oauth] Fix error in token_storage::set_user_id() PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/token_storage.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/token_storage.php b/phpBB/phpbb/auth/provider/oauth/token_storage.php index 42142b4fbe..ec54c07fea 100644 --- a/phpBB/phpbb/auth/provider/oauth/token_storage.php +++ b/phpBB/phpbb/auth/provider/oauth/token_storage.php @@ -191,7 +191,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface if ($this->user->data['user_id'] == ANONYMOUS) { - $sql .= ' AND session_id = ' . $this->user->data['session_id']; + $sql .= ' AND session_id = \'' . $this->user->data['session_id'] . '\''; } $this->db->sql_query($sql); @@ -210,11 +210,11 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface } $sql = 'UPDATE ' . $this->auth_provider_oauth_table . ' - SET ' . $db->sql_build_array('UPDATE', array( + SET ' . $this->db->sql_build_array('UPDATE', array( 'user_id' => (int) $user_id )) . ' WHERE user_id = ' . $this->user->data['user_id'] . ' - AND session_id = ' . $this->user->data['session_id']; + AND session_id = \'' . $this->user->data['session_id'] . '\''; $this->db->sql_query($sql); } } -- cgit v1.2.1 From 9cbf670f518b05cbb0600d20cfa30e3a9f4bd9e3 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 24 Jul 2013 15:31:12 -0400 Subject: [feature/oauth] Some work on login_link PHPBB3-11673 --- phpBB/includes/ucp/ucp_login_link.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_login_link.php b/phpBB/includes/ucp/ucp_login_link.php index 719dec5ea0..522a8b305c 100644 --- a/phpBB/includes/ucp/ucp_login_link.php +++ b/phpBB/includes/ucp/ucp_login_link.php @@ -27,6 +27,9 @@ class ucp_login_link function main($id, $mode) { + global $config, $phpbb_container, $request, $template; + $auth_provider = 'auth.provider.' . $request->variable('auth_provider', $config['auth_method']); + $auth_provider = $phpbb_container->get($auth_provider); } } \ No newline at end of file -- cgit v1.2.1 From f8dbaa148dccb105133b5a91d58686d79f020afe Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 24 Jul 2013 16:02:33 -0400 Subject: [feature/oauth] Fixes for problems found by tests PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/token_storage.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/token_storage.php b/phpBB/phpbb/auth/provider/oauth/token_storage.php index ec54c07fea..de99f9bd31 100644 --- a/phpBB/phpbb/auth/provider/oauth/token_storage.php +++ b/phpBB/phpbb/auth/provider/oauth/token_storage.php @@ -87,7 +87,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface } $data = array( - 'user_id' => $this->user->data['user_id'], + 'user_id' => $this->user->data['user_id'], 'provider' => $this->service_name, ); @@ -130,9 +130,9 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface $this->cachedToken = $token; $data = array( - 'user_id' => $this->user->data['user_id'], - 'provider' => $this->service_name, - 'oauth_token' => serialize($token), + 'user_id' => $this->user->data['user_id'], + 'provider' => $this->service_name, + 'oauth_token' => serialize($token), ); if ($this->user->data['user_id'] == ANONYMOUS) @@ -155,7 +155,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface } $data = array( - 'user_id' => $this->user->data['user_id'], + 'user_id' => $this->user->data['user_id'], 'provider' => $this->service_name, ); @@ -187,7 +187,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface $sql = 'DELETE FROM ' . $this->auth_provider_oauth_table . ' WHERE user_id = ' . $this->user->data['user_id'] . ' - AND provider = ' . $this->db->sql_escape($this->oauth_provider); + AND provider = \'' . $this->db->sql_escape($this->oauth_provider) . '\''; if ($this->user->data['user_id'] == ANONYMOUS) { -- cgit v1.2.1 From 7c065bc9a2b0af8f6ea1d99260cdb6498e0c1f7c Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 24 Jul 2013 16:06:19 -0400 Subject: [feature/oauth] Finish fixes from tests and tests for token storage PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/token_storage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/token_storage.php b/phpBB/phpbb/auth/provider/oauth/token_storage.php index de99f9bd31..e1cf579370 100644 --- a/phpBB/phpbb/auth/provider/oauth/token_storage.php +++ b/phpBB/phpbb/auth/provider/oauth/token_storage.php @@ -187,7 +187,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface $sql = 'DELETE FROM ' . $this->auth_provider_oauth_table . ' WHERE user_id = ' . $this->user->data['user_id'] . ' - AND provider = \'' . $this->db->sql_escape($this->oauth_provider) . '\''; + AND provider = \'' . $this->db->sql_escape($this->service_name) . '\''; if ($this->user->data['user_id'] == ANONYMOUS) { -- cgit v1.2.1 From 57bc3c7d3aaa66fc66798bc1e60b88ae17b110a9 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 25 Jul 2013 09:32:28 -0500 Subject: [ticket/11628] phpbb_template, not phpbb_template_interface PHPBB3-11628 --- phpBB/phpbb/controller/resolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/controller/resolver.php b/phpBB/phpbb/controller/resolver.php index 850df84a0f..d772507261 100644 --- a/phpBB/phpbb/controller/resolver.php +++ b/phpBB/phpbb/controller/resolver.php @@ -48,7 +48,7 @@ class phpbb_controller_resolver implements ControllerResolverInterface * * @param phpbb_user $user User Object * @param ContainerInterface $container ContainerInterface object - * @param phpbb_template_interface $template + * @param phpbb_template $template */ public function __construct(phpbb_user $user, ContainerInterface $container, phpbb_template $template = null) { -- cgit v1.2.1 From fcac58e065ed888662f5e8c99bd6cbf1943778b7 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 25 Jul 2013 11:41:04 -0400 Subject: [feature/oauth] Have login_link loaded in ucp.php PHPBB3-11673 --- phpBB/ucp.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'phpBB') diff --git a/phpBB/ucp.php b/phpBB/ucp.php index 7180c54de6..b07e0139d4 100644 --- a/phpBB/ucp.php +++ b/phpBB/ucp.php @@ -80,6 +80,15 @@ switch ($mode) login_box(request_var('redirect', "index.$phpEx")); break; + case 'login_link': + if ($user->data['is_registered']) + { + redirect(append_sid("{$phpbb_root_path}index.$phpEx")); + } + + $module->load('ucp', 'login_link'); + break; + case 'logout': if ($user->data['user_id'] != ANONYMOUS && $request->is_set('sid') && $request->variable('sid', '') === $user->session_id) { -- cgit v1.2.1 From 317a71a8384f137cedca3c9afbb02605876920c3 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 25 Jul 2013 12:49:30 -0400 Subject: [feature/oauth] Template for ucp_login_link started PHPBB3-11673 --- phpBB/includes/ucp/ucp_login_link.php | 5 ++++- phpBB/language/en/ucp.php | 2 ++ phpBB/styles/prosilver/template/ucp_login_link.html | 11 +++++++++++ phpBB/ucp.php | 1 + 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 phpBB/styles/prosilver/template/ucp_login_link.html (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_login_link.php b/phpBB/includes/ucp/ucp_login_link.php index 522a8b305c..7e6374ee83 100644 --- a/phpBB/includes/ucp/ucp_login_link.php +++ b/phpBB/includes/ucp/ucp_login_link.php @@ -31,5 +31,8 @@ class ucp_login_link $auth_provider = 'auth.provider.' . $request->variable('auth_provider', $config['auth_method']); $auth_provider = $phpbb_container->get($auth_provider); + + $this->tpl_name = 'ucp_login_link'; + $this->page_title = 'UCP_LOGIN_LINK'; } -} \ No newline at end of file +} diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index 51823ddb12..32b70e661b 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -270,6 +270,7 @@ $lang = array_merge($lang, array( 'LINK_REMOTE_SIZE' => 'Avatar dimensions', 'LINK_REMOTE_SIZE_EXPLAIN' => 'Specify the width and height of the avatar, leave blank to attempt automatic verification.', 'LOGIN_EXPLAIN_UCP' => 'Please login in order to access the User Control Panel.', + 'LOGIN_LINK' => 'Link or Register Your External Account with phpBB', 'LOGIN_KEY' => 'Login Key', 'LOGIN_TIME' => 'Login Time', 'LOGIN_REDIRECT' => 'You have been successfully logged in.', @@ -480,6 +481,7 @@ $lang = array_merge($lang, array( 'UCP_EMAIL_ACTIVATE' => 'Please note that you will need to enter a valid email address before your account is activated. You will receive an email at the address you provide that contains an account activation link.', 'UCP_ICQ' => 'ICQ number', 'UCP_JABBER' => 'Jabber address', + 'UCP_LOGIN_LINK' => 'Set up an external account', 'UCP_MAIN' => 'Overview', 'UCP_MAIN_ATTACHMENTS' => 'Manage attachments', diff --git a/phpBB/styles/prosilver/template/ucp_login_link.html b/phpBB/styles/prosilver/template/ucp_login_link.html new file mode 100644 index 0000000000..ddde41f374 --- /dev/null +++ b/phpBB/styles/prosilver/template/ucp_login_link.html @@ -0,0 +1,11 @@ + + +
+
+ +

{SITENAME} - {L_LOGIN_LINK}

+ +
+
+ + diff --git a/phpBB/ucp.php b/phpBB/ucp.php index b07e0139d4..d69d938038 100644 --- a/phpBB/ucp.php +++ b/phpBB/ucp.php @@ -87,6 +87,7 @@ switch ($mode) } $module->load('ucp', 'login_link'); + $module->display($user->lang['UCP_LOGIN_LINK']); break; case 'logout': -- cgit v1.2.1 From 59852b5997905ed6f815c3cc4b9220872e1090d2 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 25 Jul 2013 14:53:05 -0400 Subject: [feature/oauth] More work on login linking accounts PHPBB3-11673 --- phpBB/includes/ucp/ucp_login_link.php | 23 +++++++++++++++ phpBB/language/en/ucp.php | 1 + .../styles/prosilver/template/ucp_login_link.html | 34 ++++++++++++++++++++++ 3 files changed, 58 insertions(+) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_login_link.php b/phpBB/includes/ucp/ucp_login_link.php index 7e6374ee83..62641f0367 100644 --- a/phpBB/includes/ucp/ucp_login_link.php +++ b/phpBB/includes/ucp/ucp_login_link.php @@ -32,6 +32,29 @@ class ucp_login_link $auth_provider = 'auth.provider.' . $request->variable('auth_provider', $config['auth_method']); $auth_provider = $phpbb_container->get($auth_provider); + // Process POST and GET data + $login_error = false; + $login_username = ''; + + // Common template elements + $template->assign_vars(array( + 'PASSWORD_CREDENTIAL' => 'password', + 'USERNAME_CREDENTIAL' => 'username', + )); + + // Registration template + $register_link = 'ucp.php?mode=register'; + + $template->assign_vars(array( + 'REGISTER_LINK' => redirect($register_link, true), + )); + + // Link to existing account template + $template->assign_vars(array( + 'LOGIN_ERROR' => $login_error, + 'LOGIN_USERNAME' => $login_username, + )); + $this->tpl_name = 'ucp_login_link'; $this->page_title = 'UCP_LOGIN_LINK'; } diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index 32b70e661b..f44fd8905b 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -271,6 +271,7 @@ $lang = array_merge($lang, array( 'LINK_REMOTE_SIZE_EXPLAIN' => 'Specify the width and height of the avatar, leave blank to attempt automatic verification.', 'LOGIN_EXPLAIN_UCP' => 'Please login in order to access the User Control Panel.', 'LOGIN_LINK' => 'Link or Register Your External Account with phpBB', + 'LOGIN_LINK_EXPLAIN' => 'You have attempted to login with an external service that is not yet connected to an account on these forums. You may now either link this account to an existing account or you may create a new account.', 'LOGIN_KEY' => 'Login Key', 'LOGIN_TIME' => 'Login Time', 'LOGIN_REDIRECT' => 'You have been successfully logged in.', diff --git a/phpBB/styles/prosilver/template/ucp_login_link.html b/phpBB/styles/prosilver/template/ucp_login_link.html index ddde41f374..02a9873f2b 100644 --- a/phpBB/styles/prosilver/template/ucp_login_link.html +++ b/phpBB/styles/prosilver/template/ucp_login_link.html @@ -5,6 +5,40 @@

{SITENAME} - {L_LOGIN_LINK}

+

{L_LOGIN_LINK_EXPLAIN}

+ +
+

{L_REGISTER}

+
+ +
+

{L_LOGIN}

+ +
+
+
{LOGIN_ERROR}
+
+
+
+
+
+
+
+
+ + + + + + {S_LOGIN_REDIRECT} +
+
 
+
{S_HIDDEN_FIELDS}
+
+
+
+
+ -- cgit v1.2.1 From e0ef10128b68cfae9774f6c87cc1a841cacecd8d Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 26 Jul 2013 10:26:52 -0500 Subject: [ticket/11744] Group join request notification PHPBB3-11744 --- phpBB/config/notifications.yml | 18 +++ phpBB/includes/functions_user.php | 12 +- phpBB/includes/ucp/ucp_groups.php | 34 +---- phpBB/language/en/common.php | 1 + phpBB/language/en/ucp.php | 1 + phpBB/phpbb/notification/manager.php | 15 +-- phpBB/phpbb/notification/type/group_request.php | 161 ++++++++++++++++++++++++ 7 files changed, 204 insertions(+), 38 deletions(-) create mode 100644 phpBB/phpbb/notification/type/group_request.php (limited to 'phpBB') diff --git a/phpBB/config/notifications.yml b/phpBB/config/notifications.yml index 60aa63a854..04c5e46a9c 100644 --- a/phpBB/config/notifications.yml +++ b/phpBB/config/notifications.yml @@ -103,6 +103,24 @@ services: tags: - { name: notification.type } + notification.type.group_request: + class: phpbb_notification_type_group_request + scope: prototype # scope MUST be prototype for this to work! + arguments: + - @user_loader + - @dbal.conn + - @cache.driver + - @user + - @auth + - @config + - %core.root_path% + - %core.php_ext% + - %tables.notification_types% + - %tables.notifications% + - %tables.user_notifications% + tags: + - { name: notification.type } + notification.type.pm: class: phpbb_notification_type_pm scope: prototype # scope MUST be prototype for this to work! diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 1b598f7bf7..c4d96e1773 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2635,7 +2635,7 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false, */ function group_user_del($group_id, $user_id_ary = false, $username_ary = false, $group_name = false) { - global $db, $auth, $config, $phpbb_dispatcher; + global $db, $auth, $config, $phpbb_dispatcher, $phpbb_container; if ($config['coppa_enable']) { @@ -2769,6 +2769,10 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false, group_update_listings($group_id); + $phpbb_notifications = $phpbb_container->get('notification_manager'); + + $phpbb_notifications->delete_notifications('group_request', $user_id_ary, $group_id); + // Return false - no error return false; } @@ -2858,7 +2862,7 @@ function remove_default_rank($group_id, $user_ids) */ function group_user_attributes($action, $group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $group_attributes = false) { - global $db, $auth, $phpbb_root_path, $phpEx, $config; + global $db, $auth, $phpbb_root_path, $phpEx, $config, $phpbb_container; // We need both username and user_id info $result = user_get_id_name($user_id_ary, $username_ary); @@ -2951,6 +2955,10 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna $messenger->save_queue(); + $phpbb_notifications = $phpbb_container->get('notification_manager'); + + $phpbb_notifications->delete_notifications('group_request', $user_id_ary, $group_id); + $log = 'LOG_USERS_APPROVED'; break; diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index 8620e33e47..fbb0f41e21 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -198,36 +198,12 @@ class ucp_groups { 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(); + $phpbb_notifications = $phpbb_container->get('notification_manager'); - $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(); + $phpbb_notifications->add_notifications('group_request', array_merge( + $group_row[$group_id], + array('user_id' => $user->data['user_id']) + )); } 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']); diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index b188d90f3a..8ababfcd2a 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -414,6 +414,7 @@ $lang = array_merge($lang, array( 2 => '%d Notifications', ), 'NOTIFICATION_BOOKMARK' => '%1$s replied to the topic "%2$s" you have bookmarked.', + 'NOTIFICATION_GROUP_REQUEST' => '%1$s is requesting to join the group you manage, %2$s.', 'NOTIFICATION_PM' => '%1$s sent you a Private Message "%2$s".', 'NOTIFICATION_POST' => '%1$s replied to the topic "%2$s".', 'NOTIFICATION_POST_APPROVED' => 'Your post was approved "%2$s".', diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index 51823ddb12..dc09e8cdcb 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -313,6 +313,7 @@ $lang = array_merge($lang, array( 'NOTIFICATION_METHOD_JABBER' => 'Jabber', 'NOTIFICATION_TYPE' => 'Notification type', 'NOTIFICATION_TYPE_BOOKMARK' => 'Someone replies to a topic you have bookmarked', + 'NOTIFICATION_TYPE_GROUP_REQUEST' => 'Someone requests to join a group you lead', 'NOTIFICATION_TYPE_IN_MODERATION_QUEUE' => 'A post or topic needs approval', 'NOTIFICATION_TYPE_MODERATION_QUEUE' => 'Your topics/posts are approved or disapproved by a moderator', 'NOTIFICATION_TYPE_PM' => 'Someone sends you a private message', diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php index 97833710c0..4e6028ec3f 100644 --- a/phpBB/phpbb/notification/manager.php +++ b/phpBB/phpbb/notification/manager.php @@ -59,7 +59,7 @@ class phpbb_notification_manager /** * Notification Constructor - * + * * @param array $notification_types * @param array $notification_methods * @param ContainerBuilder $phpbb_container @@ -490,15 +490,15 @@ class phpbb_notification_manager * * @param string|array $notification_type_name Type identifier or array of item types (only acceptable if the $item_id is identical for the specified types) * @param int|array $item_id Identifier within the type (or array of ids) - * @param array $data Data specific for this type that will be updated + * @param bool|int|array $parent_id Parent identifier within the type (or array of ids), used in combination with item_id if specified */ - public function delete_notifications($notification_type_name, $item_id) + public function delete_notifications($notification_type_name, $item_id, $parent_id = false) { if (is_array($notification_type_name)) { foreach ($notification_type_name as $type) { - $this->delete_notifications($type, $item_id); + $this->delete_notifications($type, $item_id, $parent_id); } return; @@ -508,7 +508,8 @@ class phpbb_notification_manager $sql = 'DELETE FROM ' . $this->notifications_table . ' WHERE notification_type_id = ' . (int) $notification_type_id . ' - AND ' . (is_array($item_id) ? $this->db->sql_in_set('item_id', $item_id) : 'item_id = ' . (int) $item_id); + AND ' . (is_array($item_id) ? $this->db->sql_in_set('item_id', $item_id) : 'item_id = ' . (int) $item_id) . + (($parent_id !== false) ? ' AND ' . ((is_array($parent_id) ? $this->db->sql_in_set('item_parent_id', $parent_id) : 'item_parent_id = ' . (int) $parent_id)) : ''); $this->db->sql_query($sql); } @@ -834,12 +835,12 @@ class phpbb_notification_manager protected function load_object($object_name) { $object = $this->phpbb_container->get($object_name); - + if (method_exists($object, 'set_notification_manager')) { $object->set_notification_manager($this); } - + return $object; } diff --git a/phpBB/phpbb/notification/type/group_request.php b/phpBB/phpbb/notification/type/group_request.php new file mode 100644 index 0000000000..96015783fb --- /dev/null +++ b/phpBB/phpbb/notification/type/group_request.php @@ -0,0 +1,161 @@ + 'NOTIFICATION_TYPE_GROUP_REQUEST', + ); + + /** + * {@inheritdoc} + */ + public function is_available() + { + // Leader of any groups? + $sql = 'SELECT group_id FROM ' . USER_GROUP_TABLE . ' + WHERE user_id = ' . (int) $this->user->data['user_id'] . ' + AND group_leader = 1'; + $result = $this->db->sql_query_limit($sql, 1); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + return (!empty($row)) ? true : false; + } + + /** + * {@inheritdoc} + */ + public static function get_item_id($group) + { + return (int) $group['user_id']; + } + + /** + * {@inheritdoc} + */ + public static function get_item_parent_id($group) + { + // Group id is the parent + return (int) $group['group_id']; + } + + /** + * {@inheritdoc} + */ + public function find_users_for_notification($group, $options = array()) + { + $options = array_merge(array( + 'ignore_users' => array(), + ), $options); + + $sql = 'SELECT user_id FROM ' . USER_GROUP_TABLE . ' + WHERE group_leader = 1 + AND group_id = ' . (int) $group['group_id']; + $result = $this->db->sql_query($sql); + + $user_ids = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $user_ids[] = $row['user_id']; + } + $this->db->sql_freeresult($result); + + $this->user_loader->load_users($user_ids); + + return $this->check_user_notification_options($user_ids, $options); + } + + /** + * {@inheritdoc} + */ + public function get_avatar() + { + return $this->user_loader->get_avatar($this->item_id); + } + + /** + * {@inheritdoc} + */ + public function get_title() + { + $username = $this->user_loader->get_username($this->item_id, 'no_profile'); + + return $this->user->lang('NOTIFICATION_GROUP_REQUEST', $username, $this->get_data('group_name')); + } + + /** + * {@inheritdoc} + */ + public function get_email_template() + { + return 'group_request'; + } + + /** + * {@inheritdoc} + */ + public function get_email_template_variables() + { + $user_data = $this->user_loader->get_user($this->item_id); + + return array( + 'GROUP_NAME' => htmlspecialchars_decode($this->get_data('group_name')), + 'REQUEST_USERNAME' => htmlspecialchars_decode($user_data['username']), + + 'U_PENDING' => generate_board_url() . "/ucp.{$this->php_ext}?i=groups&mode=manage&action=list&g={$this->item_parent_id}", + 'U_GROUP' => generate_board_url() . "/memberlist.{$this->php_ext}?mode=group&g={$this->item_parent_id}", + ); + } + + /** + * {@inheritdoc} + */ + public function get_url() + { + return append_sid($this->phpbb_root_path . 'ucp.' . $this->php_ext, "i=groups&mode=manage&action=list&g={$this->item_parent_id}"); + } + + /** + * {@inheritdoc} + */ + public function users_to_query() + { + return array($this->item_id); + } + + /** + * {@inheritdoc} + */ + public function create_insert_array($group, $pre_create_data = array()) + { + $this->set_data('group_name', $group['group_name']); + + return parent::create_insert_array($group, $pre_create_data); + } +} -- cgit v1.2.1 From c260e82a9bc7961d17f2ac6698907f1a4ed392f2 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Fri, 26 Jul 2013 11:22:44 -0500 Subject: [ticket/11744] Move notification from ucp_groups to group_user_add PHPBB3-11744 --- phpBB/includes/functions_user.php | 16 +++++++++++++++- phpBB/includes/ucp/ucp_groups.php | 7 ------- 2 files changed, 15 insertions(+), 8 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index c4d96e1773..102fbaae78 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2534,7 +2534,7 @@ function group_delete($group_id, $group_name = false) */ function group_user_add($group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $default = false, $leader = 0, $pending = 0, $group_attributes = false) { - global $db, $auth; + global $db, $auth, $phpbb_container; // We need both username and user_id info $result = user_get_id_name($user_id_ary, $username_ary); @@ -2622,6 +2622,20 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false, group_update_listings($group_id); + if ($pending) + { + $phpbb_notifications = $phpbb_container->get('notification_manager'); + + foreach ($add_id_ary as $user_id) + { + $phpbb_notifications->add_notifications('group_request', array( + 'group_id' => $group_id, + 'user_id' => $user_id, + 'group_name' => $group_name, + )); + } + } + // Return false - no error return false; } diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index fbb0f41e21..6f78136f11 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -197,13 +197,6 @@ class ucp_groups else { group_user_add($group_id, $user->data['user_id'], false, false, false, 0, 1); - - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - $phpbb_notifications->add_notifications('group_request', array_merge( - $group_row[$group_id], - array('user_id' => $user->data['user_id']) - )); } 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']); -- cgit v1.2.1 From 3f230b1a8c716adb77b679fed91d50c391387b19 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Fri, 26 Jul 2013 12:29:49 -0500 Subject: [ticket/11744] Create null log class (primarily for unit test) PHPBB3-11744 --- phpBB/phpbb/log/null.php | 125 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 phpBB/phpbb/log/null.php (limited to 'phpBB') diff --git a/phpBB/phpbb/log/null.php b/phpBB/phpbb/log/null.php new file mode 100644 index 0000000000..9837058ef5 --- /dev/null +++ b/phpBB/phpbb/log/null.php @@ -0,0 +1,125 @@ + Date: Fri, 26 Jul 2013 18:27:47 -0700 Subject: [ticket/11747] Add $phpbb_dispatcher to global PHPBB3-11747 --- phpBB/includes/ucp/ucp_prefs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index f24578da84..73b01deb22 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(); -- cgit v1.2.1 From 79cd86bcbcfb2bf0f27d06fc475ea967ea38755b Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 26 Jul 2013 18:29:06 -0700 Subject: [ticket/11747] ucp_prefs_personal core events PHPBB3-11747 --- phpBB/includes/ucp/ucp_prefs.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index 73b01deb22..8a92f22bba 100644 --- a/phpBB/includes/ucp/ucp_prefs.php +++ b/phpBB/includes/ucp/ucp_prefs.php @@ -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']; -- cgit v1.2.1 From cd329c55a7bd7222982283e5a378e511c06bdfe8 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 26 Jul 2013 18:31:05 -0700 Subject: [ticket/11747] ucp_prefs_personal template events PHPBB3-11747 --- phpBB/docs/events.md | 14 ++++++++++++++ phpBB/styles/prosilver/template/ucp_prefs_personal.html | 2 ++ phpBB/styles/subsilver2/template/ucp_prefs_personal.html | 2 ++ 3 files changed, 18 insertions(+) (limited to 'phpBB') diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 3723bf7b3f..cc12410df2 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -119,6 +119,20 @@ ucp_pm_viewmessage_print_head_append * Location: styles/prosilver/template/ucp_pm_viewmessage_print.html * Purpose: Add asset calls directly before the `` tag of the Print PM screen +ucp_prefs_personal_before +=== +* Locations: + + styles/prosilver/template/ucp_prefs_personal.html + + styles/subsilver2/template/ucp_prefs_personal.html +* Purpose: Add user options to the top of the Edit Global Settings screen + +ucp_prefs_personal_after +=== +* Locations: + + styles/prosilver/template/ucp_prefs_personal.html + + styles/subsilver2/template/ucp_prefs_personal.html +* Purpose: Add user options to the bottom of the Edit Global Settings screen + viewtopic_print_head_append === * Location: styles/prosilver/template/viewtopic_print.html diff --git a/phpBB/styles/prosilver/template/ucp_prefs_personal.html b/phpBB/styles/prosilver/template/ucp_prefs_personal.html index 9a639786b7..4484dd7a55 100644 --- a/phpBB/styles/prosilver/template/ucp_prefs_personal.html +++ b/phpBB/styles/prosilver/template/ucp_prefs_personal.html @@ -9,6 +9,7 @@

{ERROR}

+
@@ -71,6 +72,7 @@
+
diff --git a/phpBB/styles/subsilver2/template/ucp_prefs_personal.html b/phpBB/styles/subsilver2/template/ucp_prefs_personal.html index 8f6e345e69..f39090c8fe 100644 --- a/phpBB/styles/subsilver2/template/ucp_prefs_personal.html +++ b/phpBB/styles/subsilver2/template/ucp_prefs_personal.html @@ -29,6 +29,7 @@ {ERROR} + {L_SHOW_EMAIL}{L_COLON} checked="checked" />{L_YES}   checked="checked" />{L_NO} @@ -75,6 +76,7 @@
style="display:none;">
+ {S_HIDDEN_FIELDS}   -- cgit v1.2.1 From d3859aa87427a75cb7c9f7645de3317a834b00ee Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 26 Jul 2013 18:31:58 -0700 Subject: [ticket/11747] ucp_prefs_view core events PHPBB3-11747 --- phpBB/includes/ucp/ucp_prefs.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index 8a92f22bba..31cf5a4447 100644 --- a/phpBB/includes/ucp/ucp_prefs.php +++ b/phpBB/includes/ucp/ucp_prefs.php @@ -234,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( @@ -272,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']; -- cgit v1.2.1 From b716e1177d0fc94f1b5b8102fd35b61a6874e324 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 26 Jul 2013 18:33:07 -0700 Subject: [ticket/11747] ucp_prefs_view template events PHPBB3-11747 --- phpBB/docs/events.md | 32 ++++++++++++++++++++++ .../styles/prosilver/template/ucp_prefs_view.html | 4 +++ .../styles/subsilver2/template/ucp_prefs_view.html | 4 +++ 3 files changed, 40 insertions(+) (limited to 'phpBB') diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index cc12410df2..93f83e8d1c 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -133,6 +133,38 @@ ucp_prefs_personal_after + styles/subsilver2/template/ucp_prefs_personal.html * Purpose: Add user options to the bottom of the Edit Global Settings screen +ucp_prefs_view_radio_buttons_before +=== +* Locations: + + styles/prosilver/template/ucp_prefs_view.html + + styles/subsilver2/template/ucp_prefs_view.html +* Purpose: Add options to the top of the radio buttons section of the Edit +Display Options screen + +ucp_prefs_view_radio_buttons_after +=== +* Locations: + + styles/prosilver/template/ucp_prefs_view.html + + styles/subsilver2/template/ucp_prefs_view.html +* Purpose: Add options to the bottom of the radio buttons section of the Edit +Display Options screen + +ucp_prefs_view_select_menu_before +=== +* Locations: + + styles/prosilver/template/ucp_prefs_view.html + + styles/subsilver2/template/ucp_prefs_view.html +* Purpose: Add options to the top of the drop down menus section of the Edit +Display Options screen + +ucp_prefs_view_select_menu_after +=== +* Locations: + + styles/prosilver/template/ucp_prefs_view.html + + styles/subsilver2/template/ucp_prefs_view.html +* Purpose: Add options to the bottom of the drop down menus section of the Edit +Display Options screen + viewtopic_print_head_append === * Location: styles/prosilver/template/viewtopic_print.html diff --git a/phpBB/styles/prosilver/template/ucp_prefs_view.html b/phpBB/styles/prosilver/template/ucp_prefs_view.html index 51561349c3..55e5531075 100644 --- a/phpBB/styles/prosilver/template/ucp_prefs_view.html +++ b/phpBB/styles/prosilver/template/ucp_prefs_view.html @@ -9,6 +9,7 @@

{ERROR}

+
@@ -53,7 +54,9 @@
+
+
{S_TOPIC_SORT_DAYS}
@@ -79,6 +82,7 @@
{S_POST_SORT_DIR}
+
diff --git a/phpBB/styles/subsilver2/template/ucp_prefs_view.html b/phpBB/styles/subsilver2/template/ucp_prefs_view.html index cc1b20a987..c9336a4da5 100644 --- a/phpBB/styles/subsilver2/template/ucp_prefs_view.html +++ b/phpBB/styles/subsilver2/template/ucp_prefs_view.html @@ -9,6 +9,7 @@ {ERROR} + {L_VIEW_IMAGES}{L_COLON} checked="checked" />{L_YES}    checked="checked" />{L_NO} @@ -35,9 +36,11 @@ checked="checked" />{L_YES}    checked="checked" />{L_NO} + + {L_VIEW_TOPICS_DAYS}{L_COLON} {S_TOPIC_SORT_DAYS} @@ -65,6 +68,7 @@ {L_VIEW_POSTS_DIR}{L_COLON} {S_POST_SORT_DIR} + {S_HIDDEN_FIELDS}   -- cgit v1.2.1 From 01e133f3563181e163aa0fc85e89a6fc35d31c0f Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 26 Jul 2013 18:33:27 -0700 Subject: [ticket/11747] ucp_prefs_post core events PHPBB3-11747 --- phpBB/includes/ucp/ucp_prefs.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index 31cf5a4447..e80cc2dce3 100644 --- a/phpBB/includes/ucp/ucp_prefs.php +++ b/phpBB/includes/ucp/ucp_prefs.php @@ -385,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')) @@ -398,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']; -- cgit v1.2.1 From 442b2a292e2b761b58f2ba88fd5922d0090ec4a5 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 26 Jul 2013 18:33:54 -0700 Subject: [ticket/11747] ucp_prefs_post template events PHPBB3-11747 --- phpBB/docs/events.md | 14 ++++++++++++++ phpBB/styles/prosilver/template/ucp_prefs_post.html | 2 ++ phpBB/styles/subsilver2/template/ucp_prefs_post.html | 2 ++ 3 files changed, 18 insertions(+) (limited to 'phpBB') diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 93f83e8d1c..74bbc675d2 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -133,6 +133,20 @@ ucp_prefs_personal_after + styles/subsilver2/template/ucp_prefs_personal.html * Purpose: Add user options to the bottom of the Edit Global Settings screen +ucp_prefs_post_before +=== +* Locations: + + styles/prosilver/template/ucp_prefs_post.html + + styles/subsilver2/template/ucp_prefs_post.html +* Purpose: Add user options to the top of the Edit Posting Defaults screen + +ucp_prefs_post_after +=== +* Locations: + + styles/prosilver/template/ucp_prefs_post.html + + styles/subsilver2/template/ucp_prefs_post.html +* Purpose: Add user options to the bottom of the Edit Posting Defaults screen + ucp_prefs_view_radio_buttons_before === * Locations: diff --git a/phpBB/styles/prosilver/template/ucp_prefs_post.html b/phpBB/styles/prosilver/template/ucp_prefs_post.html index 6c68b2bccc..2b8fea832a 100644 --- a/phpBB/styles/prosilver/template/ucp_prefs_post.html +++ b/phpBB/styles/prosilver/template/ucp_prefs_post.html @@ -8,6 +8,7 @@

{ERROR}

+
@@ -36,6 +37,7 @@
+
diff --git a/phpBB/styles/subsilver2/template/ucp_prefs_post.html b/phpBB/styles/subsilver2/template/ucp_prefs_post.html index 03f1472942..5dcd431e82 100644 --- a/phpBB/styles/subsilver2/template/ucp_prefs_post.html +++ b/phpBB/styles/subsilver2/template/ucp_prefs_post.html @@ -9,6 +9,7 @@ {ERROR} + {L_DEFAULT_BBCODE}{L_COLON} checked="checked" />{L_YES}    checked="checked" />{L_NO} @@ -25,6 +26,7 @@ {L_DEFAULT_NOTIFY}{L_COLON} checked="checked" />{L_YES}    checked="checked" />{L_NO} + {S_HIDDEN_FIELDS}   -- cgit v1.2.1 From dacca5657a59fe1e69f5609cf9112e8e2cdac369 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 26 Jul 2013 22:25:27 -0700 Subject: [ticket/11747] Use _prepend and _append for template events PHPBB3-11747 --- phpBB/docs/events.md | 16 ++++++++-------- phpBB/styles/prosilver/template/ucp_prefs_personal.html | 4 ++-- phpBB/styles/prosilver/template/ucp_prefs_post.html | 4 ++-- phpBB/styles/prosilver/template/ucp_prefs_view.html | 8 ++++---- phpBB/styles/subsilver2/template/ucp_prefs_personal.html | 4 ++-- phpBB/styles/subsilver2/template/ucp_prefs_post.html | 4 ++-- phpBB/styles/subsilver2/template/ucp_prefs_view.html | 8 ++++---- 7 files changed, 24 insertions(+), 24 deletions(-) (limited to 'phpBB') diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 74bbc675d2..f6a92aaf69 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -119,35 +119,35 @@ ucp_pm_viewmessage_print_head_append * Location: styles/prosilver/template/ucp_pm_viewmessage_print.html * Purpose: Add asset calls directly before the `` tag of the Print PM screen -ucp_prefs_personal_before +ucp_prefs_personal_prepend === * Locations: + styles/prosilver/template/ucp_prefs_personal.html + styles/subsilver2/template/ucp_prefs_personal.html * Purpose: Add user options to the top of the Edit Global Settings screen -ucp_prefs_personal_after +ucp_prefs_personal_append === * Locations: + styles/prosilver/template/ucp_prefs_personal.html + styles/subsilver2/template/ucp_prefs_personal.html * Purpose: Add user options to the bottom of the Edit Global Settings screen -ucp_prefs_post_before +ucp_prefs_post_prepend === * Locations: + styles/prosilver/template/ucp_prefs_post.html + styles/subsilver2/template/ucp_prefs_post.html * Purpose: Add user options to the top of the Edit Posting Defaults screen -ucp_prefs_post_after +ucp_prefs_post_append === * Locations: + styles/prosilver/template/ucp_prefs_post.html + styles/subsilver2/template/ucp_prefs_post.html * Purpose: Add user options to the bottom of the Edit Posting Defaults screen -ucp_prefs_view_radio_buttons_before +ucp_prefs_view_radio_buttons_prepend === * Locations: + styles/prosilver/template/ucp_prefs_view.html @@ -155,7 +155,7 @@ ucp_prefs_view_radio_buttons_before * Purpose: Add options to the top of the radio buttons section of the Edit Display Options screen -ucp_prefs_view_radio_buttons_after +ucp_prefs_view_radio_buttons_append === * Locations: + styles/prosilver/template/ucp_prefs_view.html @@ -163,7 +163,7 @@ ucp_prefs_view_radio_buttons_after * Purpose: Add options to the bottom of the radio buttons section of the Edit Display Options screen -ucp_prefs_view_select_menu_before +ucp_prefs_view_select_menu_prepend === * Locations: + styles/prosilver/template/ucp_prefs_view.html @@ -171,7 +171,7 @@ ucp_prefs_view_select_menu_before * Purpose: Add options to the top of the drop down menus section of the Edit Display Options screen -ucp_prefs_view_select_menu_after +ucp_prefs_view_select_menu_append === * Locations: + styles/prosilver/template/ucp_prefs_view.html diff --git a/phpBB/styles/prosilver/template/ucp_prefs_personal.html b/phpBB/styles/prosilver/template/ucp_prefs_personal.html index 4484dd7a55..8111496dcb 100644 --- a/phpBB/styles/prosilver/template/ucp_prefs_personal.html +++ b/phpBB/styles/prosilver/template/ucp_prefs_personal.html @@ -9,7 +9,7 @@

{ERROR}

- +
@@ -72,7 +72,7 @@
- +
diff --git a/phpBB/styles/prosilver/template/ucp_prefs_post.html b/phpBB/styles/prosilver/template/ucp_prefs_post.html index 2b8fea832a..891e49af6f 100644 --- a/phpBB/styles/prosilver/template/ucp_prefs_post.html +++ b/phpBB/styles/prosilver/template/ucp_prefs_post.html @@ -8,7 +8,7 @@

{ERROR}

- +
@@ -37,7 +37,7 @@
- +
diff --git a/phpBB/styles/prosilver/template/ucp_prefs_view.html b/phpBB/styles/prosilver/template/ucp_prefs_view.html index 55e5531075..7f8d0a344c 100644 --- a/phpBB/styles/prosilver/template/ucp_prefs_view.html +++ b/phpBB/styles/prosilver/template/ucp_prefs_view.html @@ -9,7 +9,7 @@

{ERROR}

- +
@@ -54,9 +54,9 @@
- +
- +
{S_TOPIC_SORT_DAYS}
@@ -82,7 +82,7 @@
{S_POST_SORT_DIR}
- +
diff --git a/phpBB/styles/subsilver2/template/ucp_prefs_personal.html b/phpBB/styles/subsilver2/template/ucp_prefs_personal.html index f39090c8fe..cd5fc9a13f 100644 --- a/phpBB/styles/subsilver2/template/ucp_prefs_personal.html +++ b/phpBB/styles/subsilver2/template/ucp_prefs_personal.html @@ -29,7 +29,7 @@ {ERROR} - + {L_SHOW_EMAIL}{L_COLON} checked="checked" />{L_YES}   checked="checked" />{L_NO} @@ -76,7 +76,7 @@
style="display:none;">
- + {S_HIDDEN_FIELDS}   diff --git a/phpBB/styles/subsilver2/template/ucp_prefs_post.html b/phpBB/styles/subsilver2/template/ucp_prefs_post.html index 5dcd431e82..0a558b863c 100644 --- a/phpBB/styles/subsilver2/template/ucp_prefs_post.html +++ b/phpBB/styles/subsilver2/template/ucp_prefs_post.html @@ -9,7 +9,7 @@ {ERROR} - + {L_DEFAULT_BBCODE}{L_COLON} checked="checked" />{L_YES}    checked="checked" />{L_NO} @@ -26,7 +26,7 @@ {L_DEFAULT_NOTIFY}{L_COLON} checked="checked" />{L_YES}    checked="checked" />{L_NO} - + {S_HIDDEN_FIELDS}   diff --git a/phpBB/styles/subsilver2/template/ucp_prefs_view.html b/phpBB/styles/subsilver2/template/ucp_prefs_view.html index c9336a4da5..c10c458627 100644 --- a/phpBB/styles/subsilver2/template/ucp_prefs_view.html +++ b/phpBB/styles/subsilver2/template/ucp_prefs_view.html @@ -9,7 +9,7 @@ {ERROR} - + {L_VIEW_IMAGES}{L_COLON} checked="checked" />{L_YES}    checked="checked" />{L_NO} @@ -36,11 +36,11 @@ checked="checked" />{L_YES}    checked="checked" />{L_NO} - + - + {L_VIEW_TOPICS_DAYS}{L_COLON} {S_TOPIC_SORT_DAYS} @@ -68,7 +68,7 @@ {L_VIEW_POSTS_DIR}{L_COLON} {S_POST_SORT_DIR} - + {S_HIDDEN_FIELDS}   -- cgit v1.2.1 From 93db6190f582b2af41d3bf643758e48772ea9ba0 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 27 Jul 2013 09:08:35 -0500 Subject: [ticket/11744] Language PHPBB3-11744 --- phpBB/language/en/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 8ababfcd2a..cdaf8269ed 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -414,7 +414,7 @@ $lang = array_merge($lang, array( 2 => '%d Notifications', ), 'NOTIFICATION_BOOKMARK' => '%1$s replied to the topic "%2$s" you have bookmarked.', - 'NOTIFICATION_GROUP_REQUEST' => '%1$s is requesting to join the group you manage, %2$s.', + 'NOTIFICATION_GROUP_REQUEST' => '%1$s is requesting to join the group %2$s.', 'NOTIFICATION_PM' => '%1$s sent you a Private Message "%2$s".', 'NOTIFICATION_POST' => '%1$s replied to the topic "%2$s".', 'NOTIFICATION_POST_APPROVED' => 'Your post was approved "%2$s".', -- cgit v1.2.1 From b213be84a7ff0f947de0025dcc4620142edf226b Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 27 Jul 2013 09:09:24 -0500 Subject: [ticket/11744] Comments PHPBB3-11744 --- phpBB/phpbb/notification/manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php index 4e6028ec3f..acfc984ddc 100644 --- a/phpBB/phpbb/notification/manager.php +++ b/phpBB/phpbb/notification/manager.php @@ -490,7 +490,7 @@ class phpbb_notification_manager * * @param string|array $notification_type_name Type identifier or array of item types (only acceptable if the $item_id is identical for the specified types) * @param int|array $item_id Identifier within the type (or array of ids) - * @param bool|int|array $parent_id Parent identifier within the type (or array of ids), used in combination with item_id if specified + * @param mixed $parent_id Parent identifier within the type (or array of ids), used in combination with item_id if specified (Default: false; not checked) */ public function delete_notifications($notification_type_name, $item_id, $parent_id = false) { -- cgit v1.2.1 From 9ea9afd1c431c8b6531adeac38b928f1ed6ba709 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sat, 27 Jul 2013 09:19:34 -0700 Subject: [ticket/11747] Tweak some of the wording in the events doc PHPBB3-11747 --- phpBB/docs/events.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'phpBB') diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index f6a92aaf69..300498b063 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -124,35 +124,35 @@ ucp_prefs_personal_prepend * Locations: + styles/prosilver/template/ucp_prefs_personal.html + styles/subsilver2/template/ucp_prefs_personal.html -* Purpose: Add user options to the top of the Edit Global Settings screen +* Purpose: Add user options to the top of the Edit Global Settings block ucp_prefs_personal_append === * Locations: + styles/prosilver/template/ucp_prefs_personal.html + styles/subsilver2/template/ucp_prefs_personal.html -* Purpose: Add user options to the bottom of the Edit Global Settings screen +* Purpose: Add user options to the bottom of the Edit Global Settings block ucp_prefs_post_prepend === * Locations: + styles/prosilver/template/ucp_prefs_post.html + styles/subsilver2/template/ucp_prefs_post.html -* Purpose: Add user options to the top of the Edit Posting Defaults screen +* Purpose: Add user options to the top of the Edit Posting Defaults block ucp_prefs_post_append === * Locations: + styles/prosilver/template/ucp_prefs_post.html + styles/subsilver2/template/ucp_prefs_post.html -* Purpose: Add user options to the bottom of the Edit Posting Defaults screen +* Purpose: Add user options to the bottom of the Edit Posting Defaults block ucp_prefs_view_radio_buttons_prepend === * Locations: + styles/prosilver/template/ucp_prefs_view.html + styles/subsilver2/template/ucp_prefs_view.html -* Purpose: Add options to the top of the radio buttons section of the Edit +* Purpose: Add options to the top of the radio buttons block of the Edit Display Options screen ucp_prefs_view_radio_buttons_append @@ -160,7 +160,7 @@ ucp_prefs_view_radio_buttons_append * Locations: + styles/prosilver/template/ucp_prefs_view.html + styles/subsilver2/template/ucp_prefs_view.html -* Purpose: Add options to the bottom of the radio buttons section of the Edit +* Purpose: Add options to the bottom of the radio buttons block of the Edit Display Options screen ucp_prefs_view_select_menu_prepend @@ -168,7 +168,7 @@ ucp_prefs_view_select_menu_prepend * Locations: + styles/prosilver/template/ucp_prefs_view.html + styles/subsilver2/template/ucp_prefs_view.html -* Purpose: Add options to the top of the drop down menus section of the Edit +* Purpose: Add options to the top of the drop-down lists block of the Edit Display Options screen ucp_prefs_view_select_menu_append @@ -176,7 +176,7 @@ ucp_prefs_view_select_menu_append * Locations: + styles/prosilver/template/ucp_prefs_view.html + styles/subsilver2/template/ucp_prefs_view.html -* Purpose: Add options to the bottom of the drop down menus section of the Edit +* Purpose: Add options to the bottom of the drop-down lists block of the Edit Display Options screen viewtopic_print_head_append -- cgit v1.2.1 From 46b4a405b1563c2fe15dad34c9ff2843271cd8f8 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 27 Jul 2013 17:02:45 -0500 Subject: [ticket/11745] Group request approved notification PHPBB3-11745 --- phpBB/config/notifications.yml | 18 ++++ phpBB/includes/functions_user.php | 29 ++--- phpBB/language/en/common.php | 1 + phpBB/language/en/email/group_approved.txt | 10 -- .../notification/type/group_request_approved.php | 118 +++++++++++++++++++++ 5 files changed, 143 insertions(+), 33 deletions(-) delete mode 100644 phpBB/language/en/email/group_approved.txt create mode 100644 phpBB/phpbb/notification/type/group_request_approved.php (limited to 'phpBB') diff --git a/phpBB/config/notifications.yml b/phpBB/config/notifications.yml index 04c5e46a9c..fc687cbd19 100644 --- a/phpBB/config/notifications.yml +++ b/phpBB/config/notifications.yml @@ -121,6 +121,24 @@ services: tags: - { name: notification.type } + notification.type.group_request_approved: + class: phpbb_notification_type_group_request_approved + scope: prototype # scope MUST be prototype for this to work! + arguments: + - @user_loader + - @dbal.conn + - @cache.driver + - @user + - @auth + - @config + - %core.root_path% + - %core.php_ext% + - %tables.notification_types% + - %tables.notifications% + - %tables.user_notifications% + tags: + - { name: notification.type } + notification.type.pm: class: phpbb_notification_type_pm scope: prototype # scope MUST be prototype for this to work! diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 102fbaae78..4fcce67801 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2929,11 +2929,10 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna AND ' . $db->sql_in_set('ug.user_id', $user_id_ary); $result = $db->sql_query($sql); - $user_id_ary = $email_users = array(); + $user_id_ary = array(); while ($row = $db->sql_fetchrow($result)) { $user_id_ary[] = $row['user_id']; - $email_users[] = $row; } $db->sql_freeresult($result); @@ -2948,29 +2947,13 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna AND " . $db->sql_in_set('user_id', $user_id_ary); $db->sql_query($sql); - // Send approved email to users... - include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - $messenger = new messenger(); - - foreach ($email_users as $row) - { - $messenger->template('group_approved', $row['user_lang']); - - $messenger->set_addresses($row); - - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($row['username']), - 'GROUP_NAME' => htmlspecialchars_decode($group_name), - 'U_GROUP' => generate_board_url() . "/ucp.$phpEx?i=groups&mode=membership") - ); - - $messenger->send($row['user_notify_type']); - } - - $messenger->save_queue(); - $phpbb_notifications = $phpbb_container->get('notification_manager'); + $phpbb_notifications->add_notifications('group_request_approved', array( + 'user_ids' => $user_id_ary, + 'group_id' => $group_id, + 'group_name' => $group_name, + )); $phpbb_notifications->delete_notifications('group_request', $user_id_ary, $group_id); $log = 'LOG_USERS_APPROVED'; diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index cdaf8269ed..91b1f6d9d9 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -415,6 +415,7 @@ $lang = array_merge($lang, array( ), 'NOTIFICATION_BOOKMARK' => '%1$s replied to the topic "%2$s" you have bookmarked.', 'NOTIFICATION_GROUP_REQUEST' => '%1$s is requesting to join the group %2$s.', + 'NOTIFICATION_GROUP_REQUEST_APPROVED' => 'Your request to join the "%1$s" group on has been approved.', 'NOTIFICATION_PM' => '%1$s sent you a Private Message "%2$s".', 'NOTIFICATION_POST' => '%1$s replied to the topic "%2$s".', 'NOTIFICATION_POST_APPROVED' => 'Your post was approved "%2$s".', diff --git a/phpBB/language/en/email/group_approved.txt b/phpBB/language/en/email/group_approved.txt deleted file mode 100644 index 24afefcd07..0000000000 --- a/phpBB/language/en/email/group_approved.txt +++ /dev/null @@ -1,10 +0,0 @@ -Subject: Your request has been approved - -Congratulations, - -Your request to join the "{GROUP_NAME}" group on "{SITENAME}" has been approved. -Click on the following link to see your group membership. - -{U_GROUP} - -{EMAIL_SIG} diff --git a/phpBB/phpbb/notification/type/group_request_approved.php b/phpBB/phpbb/notification/type/group_request_approved.php new file mode 100644 index 0000000000..ce83329ff3 --- /dev/null +++ b/phpBB/phpbb/notification/type/group_request_approved.php @@ -0,0 +1,118 @@ +user->lang('NOTIFICATION_GROUP_REQUEST_APPROVED', $this->get_data('group_name')); + } + + /** + * {@inheritdoc} + */ + public function get_url() + { + return append_sid($this->phpbb_root_path . 'memberlist.' . $this->php_ext, "mode=group&g={$this->item_id}"); + } + + /** + * {@inheritdoc} + */ + public function create_insert_array($group, $pre_create_data = array()) + { + $this->set_data('group_name', $group['group_name']); + + return parent::create_insert_array($group, $pre_create_data); + } + + /** + * {@inheritdoc} + */ + public function users_to_query() + { + return array(); + } + + /** + * {@inheritdoc} + */ + public function get_email_template() + { + return false; + } + + /** + * {@inheritdoc} + */ + public function get_email_template_variables() + { + return array(); + } +} -- cgit v1.2.1 From d5c56c5d503ea4b12852866e2d3b956e92a92aea Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 27 Jul 2013 20:02:03 -0500 Subject: [ticket/11724] Support "ELSE IF" and "ELSEIF" in the same way PHPBB3-11724 --- phpBB/phpbb/template/twig/lexer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index 4f88147542..1a640e559e 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -236,7 +236,8 @@ class phpbb_template_twig_lexer extends Twig_Lexer // Replace our "div by" with Twig's divisibleby (Twig does not like test names with spaces) $code = preg_replace('# div by ([0-9]+)#', ' divisibleby($1)', $code); - return preg_replace_callback('##', $callback, $code); + // (ELSE)?\s?IF; match IF|ELSEIF|ELSE IF; replace ELSE IF with ELSEIF + return preg_replace_callback('##', $callback, $code); } /** -- cgit v1.2.1 From a79e3b341578696c1dd6720d7589b10a3226dbb5 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 27 Jul 2013 20:37:50 -0500 Subject: [ticket/11373] Prune old read notifications with cron PHPBB3-11373 --- phpBB/includes/acp/acp_board.php | 1 + phpBB/language/en/acp/board.php | 2 + phpBB/phpbb/cron/task/core/prune_notifications.php | 75 ++++++++++++++++++++++ .../db/migration/data/310/notifications_cron.php | 25 ++++++++ phpBB/phpbb/notification/manager.php | 12 ++-- 5 files changed, 110 insertions(+), 5 deletions(-) create mode 100644 phpBB/phpbb/cron/task/core/prune_notifications.php create mode 100644 phpBB/phpbb/db/migration/data/310/notifications_cron.php (limited to 'phpBB') diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 12e2a1bf72..9508b03d1e 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -328,6 +328,7 @@ class acp_board 'session_length' => array('lang' => 'SESSION_LENGTH', 'validate' => 'int:60:9999999999', 'type' => 'number:60:9999999999', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']), 'active_sessions' => array('lang' => 'LIMIT_SESSIONS', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true), 'load_online_time' => array('lang' => 'ONLINE_LENGTH', 'validate' => 'int:0:999', 'type' => 'number:0:999', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']), + 'read_notification_expire_days' => array('lang' => 'READ_NOTIFICATION_EXPIRE_DAYS', 'validate' => 'int:0', 'type' => 'number:0', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']), 'legend2' => 'GENERAL_OPTIONS', 'load_notifications' => array('lang' => 'LOAD_NOTIFICATIONS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index ce15dfefb4..a07150eb11 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -367,6 +367,8 @@ $lang = array_merge($lang, array( 'LOAD_JQUERY_CDN_EXPLAIN' => 'If this setting is enabled, jQuery will be served from Google’s AJAX API CDN instead of the copy included with phpBB on your server. If the CDN fails, phpBB will attempt to fall back to the copy included with phpBB.', 'LOAD_USER_ACTIVITY' => 'Show user’s activity', 'LOAD_USER_ACTIVITY_EXPLAIN' => 'Displays active topic/forum in user profiles and user control panel. It is recommended to disable this on boards with more than one million posts.', + 'READ_NOTIFICATION_EXPIRE_DAYS' => 'Read Notification Expiration', + 'READ_NOTIFICATION_EXPIRE_DAYS_EXPLAIN' => 'Number of days that will elapse before a read notification will automatically be deleted. Set this value to 0 to make notifications permanent.', 'RECOMPILE_STYLES' => 'Recompile stale style components', 'RECOMPILE_STYLES_EXPLAIN' => 'Check for updated style components on filesystem and recompile.', 'YES_ANON_READ_MARKING' => 'Enable topic marking for guests', diff --git a/phpBB/phpbb/cron/task/core/prune_notifications.php b/phpBB/phpbb/cron/task/core/prune_notifications.php new file mode 100644 index 0000000000..6d38091e9f --- /dev/null +++ b/phpBB/phpbb/cron/task/core/prune_notifications.php @@ -0,0 +1,75 @@ +config = $config; + $this->notification_manager = $notification_manager; + } + + /** + * Runs this cron task. + * + * @return null + */ + public function run() + { + // time minus expire days in seconds + $timestamp = time() - ($this->config['read_notification_expire_days'] * 60 * 60 * 24); + $this->notification_manager->prune_notifications($timestamp); + } + + /** + * Returns whether this cron task can run, given current board configuration.= + * + * @return bool + */ + public function is_runnable() + { + return (bool) $this->config['read_notification_expire_days']; + } + + /** + * Returns whether this cron task should run now, because enough time + * has passed since it was last run. + * + * The interval between prune notifications is specified in board + * configuration. + * + * @return bool + */ + public function should_run() + { + return $this->config['read_notification_last_gc'] < time() - $this->config['read_notification_gc']; + } +} diff --git a/phpBB/phpbb/db/migration/data/310/notifications_cron.php b/phpBB/phpbb/db/migration/data/310/notifications_cron.php new file mode 100644 index 0000000000..454628e50e --- /dev/null +++ b/phpBB/phpbb/db/migration/data/310/notifications_cron.php @@ -0,0 +1,25 @@ +notifications_table . ' - WHERE notification_time < ' . (int) $timestamp; + WHERE notification_time < ' . (int) $timestamp . + (($only_read) ? ' AND notification_read = 1' : ''); $this->db->sql_query($sql); } @@ -834,12 +836,12 @@ class phpbb_notification_manager protected function load_object($object_name) { $object = $this->phpbb_container->get($object_name); - + if (method_exists($object, 'set_notification_manager')) { $object->set_notification_manager($this); } - + return $object; } -- cgit v1.2.1 From 28daa60e9e7438e663d6579a0dbbd834dba245b5 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 28 Jul 2013 21:10:17 -0500 Subject: [ticket/11744] Inheritdoc PHPBB3-11744 --- phpBB/phpbb/log/null.php | 61 ++++++------------------------------------------ 1 file changed, 7 insertions(+), 54 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/log/null.php b/phpBB/phpbb/log/null.php index 9837058ef5..14b5f65eec 100644 --- a/phpBB/phpbb/log/null.php +++ b/phpBB/phpbb/log/null.php @@ -23,12 +23,7 @@ if (!defined('IN_PHPBB')) class phpbb_log_null implements phpbb_log_interface { /** - * This function returns the state of the log system. - * - * @param string $type The log type we want to check. Empty to get - * global log status. - * - * @return bool True if log for the type is enabled + * {@inheritdoc} */ public function is_enabled($type = '') { @@ -36,46 +31,21 @@ class phpbb_log_null implements phpbb_log_interface } /** - * Disable log - * - * This function allows disabling the log system or parts of it, for this - * page call. When add_log is called and the type is disabled, - * the log will not be added to the database. - * - * @param mixed $type The log type we want to disable. Empty to - * disable all logs. Can also be an array of types. - * - * @return null + * {@inheritdoc} */ public function disable($type = '') { } /** - * Enable log - * - * This function allows re-enabling the log system. - * - * @param mixed $type The log type we want to enable. Empty to - * enable all logs. Can also be an array of types. - * - * @return null + * {@inheritdoc} */ public function enable($type = '') { } /** - * Adds a log entry to the database - * - * @param string $mode The mode defines which log_type is used and from which log the entry is retrieved - * @param int $user_id User ID of the user - * @param string $log_ip IP address of the user - * @param string $log_operation Name of the operation - * @param int $log_time Timestamp when the log entry was added, if empty time() will be used - * @param array $additional_data More arguments can be added, depending on the log_type - * - * @return int|bool Returns the log_id, if the entry was added to the database, false otherwise. + * {@inheritdoc} */ public function add($mode, $user_id, $log_ip, $log_operation, $log_time = false, $additional_data = array()) { @@ -83,20 +53,7 @@ class phpbb_log_null implements phpbb_log_interface } /** - * Grab the logs from the database - * - * @param string $mode The mode defines which log_type is used and ifrom which log the entry is retrieved - * @param bool $count_logs Shall we count all matching log entries? - * @param int $limit Limit the number of entries that are returned - * @param int $offset Offset when fetching the log entries, f.e. when paginating - * @param mixed $forum_id Restrict the log entries to the given forum_id (can also be an array of forum_ids) - * @param int $topic_id Restrict the log entries to the given topic_id - * @param int $user_id Restrict the log entries to the given user_id - * @param int $log_time Only get log entries newer than the given timestamp - * @param string $sort_by SQL order option, e.g. 'l.log_time DESC' - * @param string $keywords Will only return log entries that have the keywords in log_operation or log_data - * - * @return array The result array with the logs + * {@inheritdoc} */ public function get_logs($mode, $count_logs = true, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $log_time = 0, $sort_by = 'l.log_time DESC', $keywords = '') { @@ -104,9 +61,7 @@ class phpbb_log_null implements phpbb_log_interface } /** - * Get total log count - * - * @return int Returns the number of matching logs from the last call to get_logs() + * {@inheritdoc} */ public function get_log_count() { @@ -114,9 +69,7 @@ class phpbb_log_null implements phpbb_log_interface } /** - * Get offset of the last valid page - * - * @return int Returns the offset of the last valid page from the last call to get_logs() + * {@inheritdoc} */ public function get_valid_offset() { -- cgit v1.2.1 From cbe72ab14b528ebd986dc6fdc1d8b247ebba0df8 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 28 Jul 2013 21:15:58 -0500 Subject: [ticket/11744] Cast to int PHPBB3-11744 --- phpBB/phpbb/notification/type/group_request.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/notification/type/group_request.php b/phpBB/phpbb/notification/type/group_request.php index 96015783fb..490b9e16a3 100644 --- a/phpBB/phpbb/notification/type/group_request.php +++ b/phpBB/phpbb/notification/type/group_request.php @@ -82,7 +82,7 @@ class phpbb_notification_type_group_request extends phpbb_notification_type_base $user_ids = array(); while ($row = $this->db->sql_fetchrow($result)) { - $user_ids[] = $row['user_id']; + $user_ids[] = (int) $row['user_id']; } $this->db->sql_freeresult($result); -- cgit v1.2.1 From 0215e0bd95104c628cf084e1be0df72b2752346c Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 28 Jul 2013 21:31:12 -0500 Subject: [ticket/11724] Replace spaces with tabs PHPBB3-11724 --- phpBB/phpbb/template/twig/lexer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index 1a640e559e..7cb84167bf 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -237,7 +237,7 @@ class phpbb_template_twig_lexer extends Twig_Lexer $code = preg_replace('# div by ([0-9]+)#', ' divisibleby($1)', $code); // (ELSE)?\s?IF; match IF|ELSEIF|ELSE IF; replace ELSE IF with ELSEIF - return preg_replace_callback('##', $callback, $code); + return preg_replace_callback('##', $callback, $code); } /** -- cgit v1.2.1 From 75206c74be23e17b2661faa0693cd308cab4d382 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 29 Jul 2013 11:58:24 -0400 Subject: [feature/oauth] Basic checking for data needed in login linking PHPBB3-11673 --- phpBB/includes/ucp/ucp_login_link.php | 16 +++++++++++++++- phpBB/language/en/ucp.php | 5 +++-- phpBB/styles/prosilver/template/ucp_login_link.html | 4 ++++ 3 files changed, 22 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_login_link.php b/phpBB/includes/ucp/ucp_login_link.php index 62641f0367..1fb75deb61 100644 --- a/phpBB/includes/ucp/ucp_login_link.php +++ b/phpBB/includes/ucp/ucp_login_link.php @@ -27,17 +27,31 @@ class ucp_login_link function main($id, $mode) { - global $config, $phpbb_container, $request, $template; + global $config, $phpbb_container, $request, $template, $user; $auth_provider = 'auth.provider.' . $request->variable('auth_provider', $config['auth_method']); $auth_provider = $phpbb_container->get($auth_provider); + // Initialize necessary variables + $login_link_error = null; + + // Ensure the person was sent here with login_link data + $data = $request->variable('login_link', array()); + + if (empty($data)) + { + $login_link_error = $user->lang['LOGIN_LINK_NO_DATA_PROVIDED']; + } else { + + } + // Process POST and GET data $login_error = false; $login_username = ''; // Common template elements $template->assign_vars(array( + 'LOGIN_LINK_ERROR' => $login_link_error, 'PASSWORD_CREDENTIAL' => 'password', 'USERNAME_CREDENTIAL' => 'username', )); diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index f44fd8905b..6e48e3b801 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -270,8 +270,9 @@ $lang = array_merge($lang, array( 'LINK_REMOTE_SIZE' => 'Avatar dimensions', 'LINK_REMOTE_SIZE_EXPLAIN' => 'Specify the width and height of the avatar, leave blank to attempt automatic verification.', 'LOGIN_EXPLAIN_UCP' => 'Please login in order to access the User Control Panel.', - 'LOGIN_LINK' => 'Link or Register Your External Account with phpBB', - 'LOGIN_LINK_EXPLAIN' => 'You have attempted to login with an external service that is not yet connected to an account on these forums. You may now either link this account to an existing account or you may create a new account.', + 'LOGIN_LINK' => 'Link or Register Your External Account with phpBB', + 'LOGIN_LINK_EXPLAIN' => 'You have attempted to login with an external service that is not yet connected to an account on these forums. You may now either link this account to an existing account or you may create a new account.', + 'LOGIN_LINK_NO_DATA_PROVIDED' => 'No data has been provided to this page to link an external account to a forum account. Please contact the board administrator if you continue to experience problems.', 'LOGIN_KEY' => 'Login Key', 'LOGIN_TIME' => 'Login Time', 'LOGIN_REDIRECT' => 'You have been successfully logged in.', diff --git a/phpBB/styles/prosilver/template/ucp_login_link.html b/phpBB/styles/prosilver/template/ucp_login_link.html index 02a9873f2b..5a03e08bc5 100644 --- a/phpBB/styles/prosilver/template/ucp_login_link.html +++ b/phpBB/styles/prosilver/template/ucp_login_link.html @@ -7,6 +7,10 @@

{L_LOGIN_LINK_EXPLAIN}

+
+
{LOGIN_ERROR}
+
+

{L_REGISTER}

-- cgit v1.2.1 From bcdeafedd7178d27dcd0fafd4b22cddeaefc80b0 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 29 Jul 2013 12:55:57 -0400 Subject: [feature/oauth] Login works on login_link now, still does not actually link PHPBB3-11673 --- phpBB/includes/ucp/ucp_login_link.php | 97 +++++++++++++++++++--- .../styles/prosilver/template/ucp_login_link.html | 2 +- 2 files changed, 88 insertions(+), 11 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_login_link.php b/phpBB/includes/ucp/ucp_login_link.php index 1fb75deb61..1b9b0e45cb 100644 --- a/phpBB/includes/ucp/ucp_login_link.php +++ b/phpBB/includes/ucp/ucp_login_link.php @@ -27,7 +27,7 @@ class ucp_login_link function main($id, $mode) { - global $config, $phpbb_container, $request, $template, $user; + global $auth, $config, $phpbb_container, $request, $template, $user; $auth_provider = 'auth.provider.' . $request->variable('auth_provider', $config['auth_method']); $auth_provider = $phpbb_container->get($auth_provider); @@ -35,25 +35,84 @@ class ucp_login_link // Initialize necessary variables $login_link_error = null; - // Ensure the person was sent here with login_link data - $data = $request->variable('login_link', array()); + // 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']; - } else { - } - // Process POST and GET data - $login_error = false; - $login_username = ''; + // Have the authentication provider check that all necessary data is available + + + // 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_interface::POST); + $login_password = $request->untrimmed_variable('password', '', true, phpbb_request_interface::POST); + + $result = $auth->login($login_username, $login_password); + + 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']) ? '' : '', + ($config['email_enable']) ? '' : '', + ($config['board_contact']) ? '' : '', + ($config['board_contact']) ? '' : '' + ); + 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']], '', ''); + } + + break; + } + } else { + // The user is now logged in, attempt to link the user to the external account + $auth_provider->link_account($data); + } + } + } // Common template elements $template->assign_vars(array( 'LOGIN_LINK_ERROR' => $login_link_error, - 'PASSWORD_CREDENTIAL' => 'password', - 'USERNAME_CREDENTIAL' => 'username', + 'PASSWORD_CREDENTIAL' => 'login_password', + 'USERNAME_CREDENTIAL' => 'login_username', )); // Registration template @@ -72,4 +131,22 @@ class ucp_login_link $this->tpl_name = 'ucp_login_link'; $this->page_title = 'UCP_LOGIN_LINK'; } + + protected function get_login_link_data_array() + { + global $request; + + $var_names = $request->variable_names(phpbb_request_interface::GET); + $login_link_data = array(); + + foreach ($var_names as $var_name) + { + if (strpos($var_name, 'login_link_') === 0) + { + $login_link_data[$var_name] = $request->variable($var_name, '', false, phpbb_request_interface::GET); + } + } + + return $login_link_data; + } } diff --git a/phpBB/styles/prosilver/template/ucp_login_link.html b/phpBB/styles/prosilver/template/ucp_login_link.html index 5a03e08bc5..1c1fbdf528 100644 --- a/phpBB/styles/prosilver/template/ucp_login_link.html +++ b/phpBB/styles/prosilver/template/ucp_login_link.html @@ -8,7 +8,7 @@

{L_LOGIN_LINK_EXPLAIN}

-
{LOGIN_ERROR}
+
{LOGIN_LINK_ERROR}
-- cgit v1.2.1 From c09bda10fcf3fc7b84908bc15d86eca86b71f232 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 29 Jul 2013 13:10:56 -0400 Subject: [feature/oauth] Properly check that all data needed is available PHPBB3-11673 --- phpBB/includes/ucp/ucp_login_link.php | 13 ++++++++++--- phpBB/language/en/ucp.php | 1 + phpBB/phpbb/auth/provider/oauth/oauth.php | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_login_link.php b/phpBB/includes/ucp/ucp_login_link.php index 1b9b0e45cb..c99f162f1a 100644 --- a/phpBB/includes/ucp/ucp_login_link.php +++ b/phpBB/includes/ucp/ucp_login_link.php @@ -33,7 +33,9 @@ class ucp_login_link $auth_provider = $phpbb_container->get($auth_provider); // Initialize necessary variables + $login_error = null; $login_link_error = null; + $login_username = null; // Build the data array $data = $this->get_login_link_data_array(); @@ -45,10 +47,14 @@ class ucp_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 (!$login_link_error) { if ($request->is_set_post('login')) { @@ -143,7 +149,8 @@ class ucp_login_link { if (strpos($var_name, 'login_link_') === 0) { - $login_link_data[$var_name] = $request->variable($var_name, '', false, phpbb_request_interface::GET); + $key_name = str_replace('login_link_', '', $var_name); + $login_link_data[$key_name] = $request->variable($var_name, '', false, phpbb_request_interface::GET); } } diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index 6e48e3b801..bfc27013fe 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -272,6 +272,7 @@ $lang = array_merge($lang, array( 'LOGIN_EXPLAIN_UCP' => 'Please login in order to access the User Control Panel.', 'LOGIN_LINK' => 'Link or Register Your External Account with phpBB', 'LOGIN_LINK_EXPLAIN' => 'You have attempted to login with an external service that is not yet connected to an account on these forums. You may now either link this account to an existing account or you may create a new account.', + 'LOGIN_LINK_MISSING_DATA' => 'Data that is necessary to link your account with an external service is not available. Please restart the login process.', 'LOGIN_LINK_NO_DATA_PROVIDED' => 'No data has been provided to this page to link an external account to a forum account. Please contact the board administrator if you continue to experience problems.', 'LOGIN_KEY' => 'Login Key', 'LOGIN_TIME' => 'Login Time', diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index a8b55fc532..eaa111d194 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -337,4 +337,22 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base return $ret; } + + /** + * {@inheritdoc} + */ + public function login_link_has_necessary_data($login_link_data) + { + if (empty($login_link_data)) + { + return 'LOGIN_LINK_NO_DATA_PROVIDED'; + } + + if (!array_key_exists('oauth_service', $login_link_data) || !$login_link_data['oauth_service']) + { + return 'LOGIN_LINK_MISSING_DATA'; + } + + return null; + } } -- cgit v1.2.1 From ec160814b8bc21ab61314712660153b3f95eb7c9 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 29 Jul 2013 13:48:23 -0400 Subject: [feature/oauth] More work on getting login link working PHPBB3-11673 --- phpBB/includes/ucp/ucp_login_link.php | 140 +++++++++++++++++++--------------- 1 file changed, 79 insertions(+), 61 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_login_link.php b/phpBB/includes/ucp/ucp_login_link.php index c99f162f1a..18d07fb520 100644 --- a/phpBB/includes/ucp/ucp_login_link.php +++ b/phpBB/includes/ucp/ucp_login_link.php @@ -27,10 +27,7 @@ class ucp_login_link function main($id, $mode) { - global $auth, $config, $phpbb_container, $request, $template, $user; - - $auth_provider = 'auth.provider.' . $request->variable('auth_provider', $config['auth_method']); - $auth_provider = $phpbb_container->get($auth_provider); + global $config, $phpbb_container, $request, $template, $user; // Initialize necessary variables $login_error = null; @@ -53,83 +50,45 @@ class ucp_login_link $login_link_error = $user->lang[$result]; } + // Use the auth_provider requested even if different from configured + $auth_provider = 'auth_provider.' . (array_key_exists('auth_provider', $data)) ? $data['auth_provider'] : $config['auth_method']; + $auth_provider = $phpbb_container->get($auth_provider); + // 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_interface::POST); - $login_password = $request->untrimmed_variable('password', '', true, phpbb_request_interface::POST); - - $result = $auth->login($login_username, $login_password); + // We only care if there is or is not an error + $login_error = $this->perform_login_action(); - if ($result['status'] != LOGIN_SUCCESS) + if (!$login_error) { - // Handle all errors first - if ($result['status'] == LOGIN_BREAK) - { - trigger_error($result['error_msg']); - } + // The user is now logged in, attempt to link the user to the external account + $result = $auth_provider->link_account($data); - switch ($result['status']) + if ($result) { - 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']) ? '' : '', - ($config['email_enable']) ? '' : '', - ($config['board_contact']) ? '' : '', - ($config['board_contact']) ? '' : '' - ); - 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']], '', ''); - } - - break; + $login_link_error = $user->lang[$result]; + } else { + // Perform a redirect as the account has been linked } - } else { - // The user is now logged in, attempt to link the user to the external account - $auth_provider->link_account($data); } } } - // Common template elements + $register_link = redirect('ucp.php?mode=register', true); + $template->assign_vars(array( + // Common template elements 'LOGIN_LINK_ERROR' => $login_link_error, 'PASSWORD_CREDENTIAL' => 'login_password', 'USERNAME_CREDENTIAL' => 'login_username', - )); - // Registration template - $register_link = 'ucp.php?mode=register'; - - $template->assign_vars(array( - 'REGISTER_LINK' => redirect($register_link, true), - )); + // Registration elements + 'REGISTER_LINK' => $register_link, - // Link to existing account template - $template->assign_vars(array( + // Login elements 'LOGIN_ERROR' => $login_error, 'LOGIN_USERNAME' => $login_username, )); @@ -156,4 +115,63 @@ class ucp_login_link return $login_link_data; } + + protected function perform_login_action() + { + global $auth, $config, $request, $template, $user; + $login_username = $request->variable('login_username', '', false, phpbb_request_interface::POST); + $login_password = $request->untrimmed_variable('password', '', true, phpbb_request_interface::POST); + + $result = $auth->login($login_username, $login_password); + + $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']) ? '' : '', + ($config['email_enable']) ? '' : '', + ($config['board_contact']) ? '' : '', + ($config['board_contact']) ? '' : '' + ); + 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']], '', ''); + } + + break; + } + } + + return $login_error; + } } -- cgit v1.2.1 From 600c29e6ecc189aed1ba6b993c3fe79033285df1 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 29 Jul 2013 14:01:44 -0400 Subject: [feature/oauth] Most of ucp page related to login option should be done now PHPBB3-11673 --- phpBB/includes/ucp/ucp_login_link.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_login_link.php b/phpBB/includes/ucp/ucp_login_link.php index 18d07fb520..c2fc0fdfab 100644 --- a/phpBB/includes/ucp/ucp_login_link.php +++ b/phpBB/includes/ucp/ucp_login_link.php @@ -43,6 +43,10 @@ class ucp_login_link $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); + // Have the authentication provider check that all necessary data is available $result = $auth_provider->login_link_has_necessary_data($data); if ($result !== null) @@ -50,10 +54,6 @@ class ucp_login_link $login_link_error = $user->lang[$result]; } - // Use the auth_provider requested even if different from configured - $auth_provider = 'auth_provider.' . (array_key_exists('auth_provider', $data)) ? $data['auth_provider'] : $config['auth_method']; - $auth_provider = $phpbb_container->get($auth_provider); - // Perform link action if there is no error if (!$login_link_error) { @@ -72,6 +72,7 @@ class ucp_login_link $login_link_error = $user->lang[$result]; } else { // Perform a redirect as the account has been linked + $this->perform_redirect(); } } } @@ -120,7 +121,7 @@ class ucp_login_link { global $auth, $config, $request, $template, $user; $login_username = $request->variable('login_username', '', false, phpbb_request_interface::POST); - $login_password = $request->untrimmed_variable('password', '', true, phpbb_request_interface::POST); + $login_password = $request->untrimmed_variable('login_password', '', true, phpbb_request_interface::POST); $result = $auth->login($login_username, $login_password); @@ -174,4 +175,10 @@ class ucp_login_link return $login_error; } + + protected function perform_redirect() + { + // TODO: Make redirect to same page as login would have + redirect('index.php'); + } } -- cgit v1.2.1 From 9eb4d55e8215d93256ae4ea241d40efa1d5b5854 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 29 Jul 2013 14:27:12 -0400 Subject: [feature/oauth] Start work on linking an oauth account Updates token storage to allow retrieval only by session_id PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 36 +++++++ phpBB/phpbb/auth/provider/oauth/token_storage.php | 123 +++++++++++++++++----- 2 files changed, 130 insertions(+), 29 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index eaa111d194..0bcbcda74e 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -355,4 +355,40 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base return null; } + + /** + * {@inheritdoc} + */ + public function link_account(array $link_data) + { + // We must have an oauth_service listed, check for it two ways + if (!array_key_exists('oauth_service', $link_data) || !$link_data['oauth_service']) + { + if (!$link_data['oauth_service'] && $this->request->is_set('oauth_service')) + { + $link_data['oauth_service'] = $this->request->variable('oauth_service', ''); + } + + if (!$link_data['oauth_service']) + { + return 'LOGIN_LINK_MISSING_DATA'; + } + } + + $service_name = 'auth.provider.oauth.service.' . strtolower($link_data['oauth_service']); + if (!array_key_exists($service_name, $this->service_providers)) + { + return 'LOGIN_ERROR_OAUTH_SERVICE_DOES_NOT_EXIST'; + } + + $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_token_storage_table); + + // Check for an access token, they should have one + if (!$storage->has_access_token_by_sesion()) + { + return 'LOGIN_LINK_ERROR_OAUTH_NO_ACCESS_TOKEN'; + } + + $token = $storage->retrieve_access_token_by_session(); + } } diff --git a/phpBB/phpbb/auth/provider/oauth/token_storage.php b/phpBB/phpbb/auth/provider/oauth/token_storage.php index e1cf579370..af85f5598f 100644 --- a/phpBB/phpbb/auth/provider/oauth/token_storage.php +++ b/phpBB/phpbb/auth/provider/oauth/token_storage.php @@ -96,30 +96,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface $data['session_id'] = $this->user->data['session_id']; } - $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . ' - WHERE ' . $this->db->sql_build_array('SELECT', $data); - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); - - if (!$row) - { - // TODO: translate - throw new TokenNotFoundException('Token not stored'); - } - - $token = unserialize($row['oauth_token']); - - // Ensure that the token was serialized/unserialized correctly - if (!($token instanceof TokenInterface)) - { - $this->clearToken(); - // TODO: translate - throw new TokenNotFoundException('Token not stored correctly'); - } - - $this->cachedToken = $token; - return $token; + return $this->_retrieve_access_token($data); } /** @@ -164,11 +141,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface $data['session_id'] = $this->user->data['session_id']; } - $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . ' - WHERE ' . $this->db->sql_build_array('SELECT', $data); - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); + $row = $this->_has_acess_token($data); if (!$row) { @@ -217,4 +190,96 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface AND session_id = \'' . $this->user->data['session_id'] . '\''; $this->db->sql_query($sql); } + + /** + * Checks to see if an access token exists solely by the session_id of the user + * + * @return bool true if they have token, false if they don't + */ + public function has_access_token_by_session() + { + if( $this->cachedToken ) { + return true; + } + + $data = array( + 'session_id' => $this->user->data['session_id'], + 'provider' => $this->service_name, + ); + + $row = $this->_has_acess_token($data); + + if (!$row) + { + return false; + } + + return true; + } + + /** + * A helper function that performs the query for has access token functions + * + * @param array $data + * @return mixed + */ + protected function _has_acess_token($data) + { + $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . ' + WHERE ' . $this->db->sql_build_array('SELECT', $data); + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + return $row; + } + + public function retrieve_access_token_by_session() + { + if( $this->cachedToken instanceOf TokenInterface ) { + return $this->cachedToken; + } + + $data = array( + 'session_id' => $this->user->data['session_id'], + 'provider' => $this->service_name, + ); + + return $this->_retrieve_access_token($data); + } + + /** + * A helper function that performs the query for retrieve access token functions + * Also checks if the token is a valid token + * + * @param array $data + * @return mixed + */ + protected function _retrieve_access_token($data) + { + $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . ' + WHERE ' . $this->db->sql_build_array('SELECT', $data); + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if (!$row) + { + // TODO: translate + throw new TokenNotFoundException('Token not stored'); + } + + $token = unserialize($row['oauth_token']); + + // Ensure that the token was serialized/unserialized correctly + if (!($token instanceof TokenInterface)) + { + $this->clearToken(); + // TODO: translate + throw new TokenNotFoundException('Token not stored correctly'); + } + + $this->cachedToken = $token; + return $token; + } } -- cgit v1.2.1 From 641433920e43478a021743557f69382292f60f68 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 29 Jul 2013 15:07:24 -0400 Subject: [feature/oauth] Worked in at least one test PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 0bcbcda74e..56655fdfd9 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -177,8 +177,8 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base 'error_msg' => 'LOGIN_OAUTH_ACCOUNT_NOT_LINKED', 'user_row' => array(), 'redirect_data' => array( - 'auth_provider' => 'oauth', - 'oauth_service' => $service_name_original, + 'auth_provider' => 'oauth', + 'login_link_oauth_service' => $service_name_original, ), ); } @@ -384,11 +384,30 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_token_storage_table); // Check for an access token, they should have one - if (!$storage->has_access_token_by_sesion()) + if (!$storage->has_access_token_by_session()) { return 'LOGIN_LINK_ERROR_OAUTH_NO_ACCESS_TOKEN'; } - $token = $storage->retrieve_access_token_by_session(); + // Prepare for an authentication request + $this->get_current_uri(strtolower($link_data['oauth_service'])); + $this->current_uri->setQuery('mode=login_link&login_link_oauth_service=' . $service_name); + $service_credentials = $this->service_providers[$service_name]->get_service_credentials(); + $scopes = $this->service_providers[$service_name]->get_auth_scope(); + $service = $this->get_service($service_name, $storage, $service_credentials, $scopes); + $this->service_providers[$service_name]->set_external_service_provider($service); + + // The user has already authenticated successfully, request to authenticate again + $unique_id = $this->service_providers[$service_name]->perform_auth_login(); + + // Insert into table, they will be able to log in after this + $data = array( + 'user_id' => $this->user->data['user_id'], + 'provider' => strtolower($link_data['oauth_service']), + 'oauth_provider_id' => $unique_id, + ); + $sql = 'INSERT INTO ' . $this->auth_provider_oauth_token_account_assoc . ' + ' . $this->db->sql_build_array('INSERT', $data); + $this->db->sql_query($sql); } } -- cgit v1.2.1 From 3d55e5faa91f0161bc020720a81b50171b30f49d Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 29 Jul 2013 16:03:54 -0400 Subject: [feature/oauth] Works in all tests now PHPBB3-11673 --- phpBB/includes/ucp/ucp_login_link.php | 21 ++++++++++++++------- phpBB/phpbb/auth/provider/oauth/oauth.php | 6 +++--- phpBB/phpbb/auth/provider/oauth/service/google.php | 20 +++++++++++++++++++- 3 files changed, 36 insertions(+), 11 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_login_link.php b/phpBB/includes/ucp/ucp_login_link.php index c2fc0fdfab..5b58e91b9a 100644 --- a/phpBB/includes/ucp/ucp_login_link.php +++ b/phpBB/includes/ucp/ucp_login_link.php @@ -59,11 +59,19 @@ class ucp_login_link { if ($request->is_set_post('login')) { + $login_username = $request->variable('login_username', '', false, phpbb_request_interface::POST); + $login_password = $request->untrimmed_variable('login_password', '', true, phpbb_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->perform_login_action(); + $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); @@ -71,6 +79,9 @@ class ucp_login_link { $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(); } @@ -117,13 +128,9 @@ class ucp_login_link return $login_link_data; } - protected function perform_login_action() + protected function process_login_result($result) { - global $auth, $config, $request, $template, $user; - $login_username = $request->variable('login_username', '', false, phpbb_request_interface::POST); - $login_password = $request->untrimmed_variable('login_password', '', true, phpbb_request_interface::POST); - - $result = $auth->login($login_username, $login_password); + global $config, $request, $template, $user; $login_error = null; diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 56655fdfd9..6526667794 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -394,15 +394,15 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base $this->current_uri->setQuery('mode=login_link&login_link_oauth_service=' . $service_name); $service_credentials = $this->service_providers[$service_name]->get_service_credentials(); $scopes = $this->service_providers[$service_name]->get_auth_scope(); - $service = $this->get_service($service_name, $storage, $service_credentials, $scopes); + $service = $this->get_service(strtolower($link_data['oauth_service']), $storage, $service_credentials, $scopes); $this->service_providers[$service_name]->set_external_service_provider($service); // The user has already authenticated successfully, request to authenticate again - $unique_id = $this->service_providers[$service_name]->perform_auth_login(); + $unique_id = $this->service_providers[$service_name]->perform_auth_link(); // Insert into table, they will be able to log in after this $data = array( - 'user_id' => $this->user->data['user_id'], + 'user_id' => $link_data['user_id'], 'provider' => strtolower($link_data['oauth_service']), 'oauth_provider_id' => $unique_id, ); diff --git a/phpBB/phpbb/auth/provider/oauth/service/google.php b/phpBB/phpbb/auth/provider/oauth/service/google.php index 3e5735b97c..c5de1e01d2 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/google.php +++ b/phpBB/phpbb/auth/provider/oauth/service/google.php @@ -81,7 +81,7 @@ class phpbb_auth_provider_oauth_service_google extends phpbb_auth_provider_oauth throw new Exception('Invalid service provider type'); } - // This was a callback request from bitly, get the token + // This was a callback request, get the token $this->service_provider->requestAccessToken( $this->request->variable('code', '') ); // Send a request with it @@ -90,4 +90,22 @@ class phpbb_auth_provider_oauth_service_google extends phpbb_auth_provider_oauth // Return the unique identifier returned from bitly return $result['id']; } + + /** + * {@inheritdoc} + */ + public function perform_auth_link() + { + if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Google)) + { + // TODO: make exception class and use language constant + throw new Exception('Invalid service provider type'); + } + + // Send a request with it + $result = json_decode( $this->service_provider->request('https://www.googleapis.com/oauth2/v1/userinfo'), true ); + + // Return the unique identifier returned from bitly + return $result['id']; + } } -- cgit v1.2.1 From d21ab4f629342d9f1bb46f489f166c9016ebe72b Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 29 Jul 2013 16:07:11 -0400 Subject: [feature/oauth] Update the OAuth service interface PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 2 +- phpBB/phpbb/auth/provider/oauth/service/bitly.php | 18 ++++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/facebook.php | 18 ++++++++++++++++++ phpBB/phpbb/auth/provider/oauth/service/google.php | 2 +- phpBB/phpbb/auth/provider/oauth/service/interface.php | 9 +++++++++ 5 files changed, 47 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 6526667794..4266a8de0d 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -398,7 +398,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base $this->service_providers[$service_name]->set_external_service_provider($service); // The user has already authenticated successfully, request to authenticate again - $unique_id = $this->service_providers[$service_name]->perform_auth_link(); + $unique_id = $this->service_providers[$service_name]->perform_token_auth(); // Insert into table, they will be able to log in after this $data = array( diff --git a/phpBB/phpbb/auth/provider/oauth/service/bitly.php b/phpBB/phpbb/auth/provider/oauth/service/bitly.php index b6b99c0850..9b8e7ebb03 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/bitly.php +++ b/phpBB/phpbb/auth/provider/oauth/service/bitly.php @@ -79,4 +79,22 @@ class phpbb_auth_provider_oauth_service_bitly extends phpbb_auth_provider_oauth_ // Return the unique identifier returned from bitly return $result['data']['login']; } + + /** + * {@inheritdoc} + */ + public function perform_token_auth() + { + if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Bitly)) + { + // TODO: make exception class and use language constant + throw new Exception('Invalid service provider type'); + } + + // Send a request with it + $result = json_decode( $this->service_provider->request('user/info'), true ); + + // Return the unique identifier returned from bitly + return $result['data']['login']; + } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/facebook.php b/phpBB/phpbb/auth/provider/oauth/service/facebook.php index 4758ae11f8..16919081cc 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/facebook.php +++ b/phpBB/phpbb/auth/provider/oauth/service/facebook.php @@ -79,4 +79,22 @@ class phpbb_auth_provider_oauth_service_facebook extends phpbb_auth_provider_oau // Return the unique identifier returned from bitly return $result['id']; } + + /** + * {@inheritdoc} + */ + public function perform_token_auth() + { + if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Facebook)) + { + // TODO: make exception class and use language constant + throw new Exception('Invalid service provider type'); + } + + // Send a request with it + $result = json_decode( $this->service_provider->request('/me'), true ); + + // Return the unique identifier returned from bitly + return $result['id']; + } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/google.php b/phpBB/phpbb/auth/provider/oauth/service/google.php index c5de1e01d2..b49a833cce 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/google.php +++ b/phpBB/phpbb/auth/provider/oauth/service/google.php @@ -94,7 +94,7 @@ class phpbb_auth_provider_oauth_service_google extends phpbb_auth_provider_oauth /** * {@inheritdoc} */ - public function perform_auth_link() + public function perform_token_auth() { if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Google)) { diff --git a/phpBB/phpbb/auth/provider/oauth/service/interface.php b/phpBB/phpbb/auth/provider/oauth/service/interface.php index a69148695d..0d6ae7417f 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/interface.php +++ b/phpBB/phpbb/auth/provider/oauth/service/interface.php @@ -57,6 +57,15 @@ interface phpbb_auth_provider_oauth_service_interface */ public function perform_auth_login(); + /** + * Returns the results of the authentication in json format + * Use this function when the user already has an access token + * + * @return string The unique identifier returned by the service provider + * that is used to authenticate the user with phpBB. + */ + public function perform_token_auth(); + /** * Sets the external library service provider * -- cgit v1.2.1 From e91b73e62d32a031625651133a51e9310cfcadbf Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 29 Jul 2013 16:12:36 -0400 Subject: [feature/oauth] Update the auth interface PHPBB3-11673 --- phpBB/phpbb/auth/provider/base.php | 16 ++++++++++++++++ phpBB/phpbb/auth/provider/interface.php | 20 ++++++++++++++++++++ 2 files changed, 36 insertions(+) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/base.php b/phpBB/phpbb/auth/provider/base.php index 7eaf8bb2d3..ca1c635b15 100644 --- a/phpBB/phpbb/auth/provider/base.php +++ b/phpBB/phpbb/auth/provider/base.php @@ -69,4 +69,20 @@ abstract class phpbb_auth_provider_base implements phpbb_auth_provider_interface { return; } + + /** + * {@inheritdoc} + */ + public function login_link_has_necessary_data($login_link_data) + { + return; + } + + /** + * {@inheritdoc} + */ + public function link_account(array $link_data) + { + return; + } } diff --git a/phpBB/phpbb/auth/provider/interface.php b/phpBB/phpbb/auth/provider/interface.php index 9cee63abeb..a2d57a6917 100644 --- a/phpBB/phpbb/auth/provider/interface.php +++ b/phpBB/phpbb/auth/provider/interface.php @@ -125,4 +125,24 @@ interface phpbb_auth_provider_interface * session should be closed, or null if not implemented. */ public function validate_session($user); + + /** + * Checks to see if $login_link_data contains all information except for the + * user_id of an account needed to successfully link an external account to + * a forum account. + * + * @param array $link_data Any data needed to link a phpBB account to + * an external account. + * @return string|null Returns a string with a language constant if there + * is data missing or null if there is no error. + */ + public function login_link_has_necessary_data($login_link_data); + + /** + * Links an external account to a phpBB account. + * + * @param array $link_data Any data needed to link a phpBB account to + * an external account. + */ + public function link_account(array $link_data); } -- cgit v1.2.1 From e53ebb1b68494690749472378de1044d31645f17 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 29 Jul 2013 16:28:12 -0400 Subject: [feature/oauth] Update user_id on the access token PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 4266a8de0d..cfeee94439 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -409,5 +409,8 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base $sql = 'INSERT INTO ' . $this->auth_provider_oauth_token_account_assoc . ' ' . $this->db->sql_build_array('INSERT', $data); $this->db->sql_query($sql); + + // Update token storage to store the user_id + $storage->set_user_id($link_data['user_id']); } } -- cgit v1.2.1 From bf9d4e0cdf0fc99555ebd9860665ce898a8d9497 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Tue, 30 Jul 2013 14:08:13 -0400 Subject: [feature/oauth] Consolidate repeated query into one function PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/token_storage.php | 56 +++++++++++------------ 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/token_storage.php b/phpBB/phpbb/auth/provider/oauth/token_storage.php index af85f5598f..b38029c650 100644 --- a/phpBB/phpbb/auth/provider/oauth/token_storage.php +++ b/phpBB/phpbb/auth/provider/oauth/token_storage.php @@ -141,14 +141,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface $data['session_id'] = $this->user->data['session_id']; } - $row = $this->_has_acess_token($data); - - if (!$row) - { - return false; - } - - return true; + return $this->_has_acess_token($data); } /** @@ -207,31 +200,25 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface 'provider' => $this->service_name, ); - $row = $this->_has_acess_token($data); - - if (!$row) - { - return false; - } - - return true; + return $this->_has_acess_token($data); } /** * A helper function that performs the query for has access token functions * * @param array $data - * @return mixed + * @return bool */ protected function _has_acess_token($data) { - $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . ' - WHERE ' . $this->db->sql_build_array('SELECT', $data); - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); + $row = $this->get_access_token_row($data); - return $row; + if (!$row) + { + return false; + } + + return true; } public function retrieve_access_token_by_session() @@ -257,11 +244,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface */ protected function _retrieve_access_token($data) { - $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . ' - WHERE ' . $this->db->sql_build_array('SELECT', $data); - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); + $row = $this->get_access_token_row($data); if (!$row) { @@ -282,4 +265,21 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface $this->cachedToken = $token; return $token; } + + /** + * A helper function that performs the query for retrieving an access token + * + * @param array $data + * @return mixed + */ + protected function get_access_token_row($data) + { + $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . ' + WHERE ' . $this->db->sql_build_array('SELECT', $data); + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + return $row; + } } -- cgit v1.2.1 From b74e65801a17ec5d221661ac92f1c437cc7ade1a Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Tue, 30 Jul 2013 14:14:48 -0400 Subject: [feature/oauth] Clean up documentation PHPBB3-11673 --- phpBB/phpbb/auth/provider/interface.php | 2 +- phpBB/phpbb/auth/provider/oauth/service/facebook.php | 6 +++--- phpBB/phpbb/auth/provider/oauth/service/google.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/interface.php b/phpBB/phpbb/auth/provider/interface.php index a2d57a6917..fd3fa7d879 100644 --- a/phpBB/phpbb/auth/provider/interface.php +++ b/phpBB/phpbb/auth/provider/interface.php @@ -87,7 +87,7 @@ interface phpbb_auth_provider_interface * ) * An optional third element may be added to this * array: 'BLOCK_VAR_NAME'. If this is present, - * then it's value should be a string that is used + * then its value should be a string that is used * to designate the name of the loop used in the * ACP template file. In addition to this, an * additional key named 'BLOCK_VARS' is required. diff --git a/phpBB/phpbb/auth/provider/oauth/service/facebook.php b/phpBB/phpbb/auth/provider/oauth/service/facebook.php index 16919081cc..dc742cca0d 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/facebook.php +++ b/phpBB/phpbb/auth/provider/oauth/service/facebook.php @@ -70,13 +70,13 @@ class phpbb_auth_provider_oauth_service_facebook extends phpbb_auth_provider_oau throw new Exception('Invalid service provider type'); } - // This was a callback request from bitly, get the token + // This was a callback request, get the token $this->service_provider->requestAccessToken( $this->request->variable('code', '') ); // Send a request with it $result = json_decode( $this->service_provider->request('/me'), true ); - // Return the unique identifier returned from bitly + // Return the unique identifier return $result['id']; } @@ -94,7 +94,7 @@ class phpbb_auth_provider_oauth_service_facebook extends phpbb_auth_provider_oau // Send a request with it $result = json_decode( $this->service_provider->request('/me'), true ); - // Return the unique identifier returned from bitly + // Return the unique identifier return $result['id']; } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/google.php b/phpBB/phpbb/auth/provider/oauth/service/google.php index b49a833cce..e2b0f7d36a 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/google.php +++ b/phpBB/phpbb/auth/provider/oauth/service/google.php @@ -87,7 +87,7 @@ class phpbb_auth_provider_oauth_service_google extends phpbb_auth_provider_oauth // Send a request with it $result = json_decode( $this->service_provider->request('https://www.googleapis.com/oauth2/v1/userinfo'), true ); - // Return the unique identifier returned from bitly + // Return the unique identifier return $result['id']; } @@ -105,7 +105,7 @@ class phpbb_auth_provider_oauth_service_google extends phpbb_auth_provider_oauth // Send a request with it $result = json_decode( $this->service_provider->request('https://www.googleapis.com/oauth2/v1/userinfo'), true ); - // Return the unique identifier returned from bitly + // Return the unique identifier return $result['id']; } } -- cgit v1.2.1 From c5515eaf5466f2122a69c35aacd17b3614f46462 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Tue, 30 Jul 2013 14:16:25 -0400 Subject: [feature/oauth] Reword some of the language text PHPBB3-11673 --- phpBB/language/en/ucp.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index bfc27013fe..101fc7663a 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -270,8 +270,8 @@ $lang = array_merge($lang, array( 'LINK_REMOTE_SIZE' => 'Avatar dimensions', 'LINK_REMOTE_SIZE_EXPLAIN' => 'Specify the width and height of the avatar, leave blank to attempt automatic verification.', 'LOGIN_EXPLAIN_UCP' => 'Please login in order to access the User Control Panel.', - 'LOGIN_LINK' => 'Link or Register Your External Account with phpBB', - 'LOGIN_LINK_EXPLAIN' => 'You have attempted to login with an external service that is not yet connected to an account on these forums. You may now either link this account to an existing account or you may create a new account.', + 'LOGIN_LINK' => 'Link or Register Your External Account with This Board', + 'LOGIN_LINK_EXPLAIN' => 'You have attempted to login with an external service that is not yet connected to an account on this board. You must now either link this account to an existing account or create a new account.', 'LOGIN_LINK_MISSING_DATA' => 'Data that is necessary to link your account with an external service is not available. Please restart the login process.', 'LOGIN_LINK_NO_DATA_PROVIDED' => 'No data has been provided to this page to link an external account to a forum account. Please contact the board administrator if you continue to experience problems.', 'LOGIN_KEY' => 'Login Key', -- cgit v1.2.1 From 6a45cd7bcafda208a6e0f096c8cc8c0fc45abe16 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Tue, 30 Jul 2013 14:30:49 -0400 Subject: [feature/oauth] Login_link register form PHPBB3-11673 --- phpBB/styles/prosilver/template/ucp_login_link.html | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'phpBB') diff --git a/phpBB/styles/prosilver/template/ucp_login_link.html b/phpBB/styles/prosilver/template/ucp_login_link.html index 1c1fbdf528..baf7d56176 100644 --- a/phpBB/styles/prosilver/template/ucp_login_link.html +++ b/phpBB/styles/prosilver/template/ucp_login_link.html @@ -13,6 +13,15 @@

{L_REGISTER}

+ +
+
+
+
 
+
{S_HIDDEN_FIELDS}
+
+
+
-- cgit v1.2.1 From 0cbfa8ffd465bdff113bdbc92326c2d272afe15d Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Tue, 30 Jul 2013 14:45:05 -0400 Subject: [feature/oauth] Start working on login_link registration support PHPBB3-11673 --- phpBB/includes/ucp/ucp_login_link.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_login_link.php b/phpBB/includes/ucp/ucp_login_link.php index 5b58e91b9a..73991dc1a4 100644 --- a/phpBB/includes/ucp/ucp_login_link.php +++ b/phpBB/includes/ucp/ucp_login_link.php @@ -89,8 +89,6 @@ class ucp_login_link } } - $register_link = redirect('ucp.php?mode=register', true); - $template->assign_vars(array( // Common template elements 'LOGIN_LINK_ERROR' => $login_link_error, @@ -98,7 +96,7 @@ class ucp_login_link 'USERNAME_CREDENTIAL' => 'login_username', // Registration elements - 'REGISTER_LINK' => $register_link, + 'REGISTER_ACTION' => $this->get_register_redirect($data), // Login elements 'LOGIN_ERROR' => $login_error, @@ -109,6 +107,20 @@ class ucp_login_link $this->page_title = 'UCP_LOGIN_LINK'; } + protected function get_register_redirect($data) + { + global $config, $phpbb_root_path, $phpEx, $request; + + $params = 'mode=register&login_link=1&auth_provider=' . $request->variable('auth_provider', $config['auth_method']); + + foreach ($data as $key => $value) + { + $params .= '&login_link_' . $key . '=' . $value; + } + + return append_sid("{$phpbb_root_path}ucp.$phpEx", $params); + } + protected function get_login_link_data_array() { global $request; -- cgit v1.2.1 From b6d93d21bade3cab9f9434e6a87802913587feae Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 31 Jul 2013 13:46:40 -0400 Subject: [feature/oauth] Login_link in registration PHPBB3-11673 --- phpBB/includes/ucp/ucp_login_link.php | 11 ++++---- phpBB/includes/ucp/ucp_register.php | 52 +++++++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 7 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_login_link.php b/phpBB/includes/ucp/ucp_login_link.php index 73991dc1a4..e60628e3c1 100644 --- a/phpBB/includes/ucp/ucp_login_link.php +++ b/phpBB/includes/ucp/ucp_login_link.php @@ -94,9 +94,10 @@ class ucp_login_link 'LOGIN_LINK_ERROR' => $login_link_error, 'PASSWORD_CREDENTIAL' => 'login_password', 'USERNAME_CREDENTIAL' => 'login_username', + 'S_HIDDEN_FIELDS' => $this->get_hidden_fields(), // Registration elements - 'REGISTER_ACTION' => $this->get_register_redirect($data), + 'REGISTER_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'), // Login elements 'LOGIN_ERROR' => $login_error, @@ -107,18 +108,18 @@ class ucp_login_link $this->page_title = 'UCP_LOGIN_LINK'; } - protected function get_register_redirect($data) + protected function get_register_hidden_fields($data) { global $config, $phpbb_root_path, $phpEx, $request; - $params = 'mode=register&login_link=1&auth_provider=' . $request->variable('auth_provider', $config['auth_method']); + $fields = array(); foreach ($data as $key => $value) { - $params .= '&login_link_' . $key . '=' . $value; + $fields['login_link_' . $key] = $value; } - return append_sid("{$phpbb_root_path}ucp.$phpEx", $params); + return build_hidden_fields($s_hidden_fields); } protected function get_login_link_data_array() diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index 70fbfe46fb..d52e172ec2 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,11 +78,28 @@ class ucp_register } } - $cp = new custom_profile(); $error = $cp_data = $cp_error = array(); + // Handle login_link data added to $_hidden_fields + $login_link_data = $this->get_login_link_data_array(); + + if ($login_link_data !== array()) + { + // 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($data); + if ($result !== null) + { + $error[] = $user->lang[$result]; + } + + $s_hidden_fields = array_merge($s_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) : ''; @@ -398,6 +415,19 @@ class ucp_register } } + // Perform account linking if necessary + if ($login_link_data !== array()) + { + $login_link_data['user_id'] = $user_id; + + $result = $auth_provider->link_account($login_link_data); + + if ($result) + { + $message = $message . '

' . $user->lang[$result]; + } + } + $message = $message . '

' . sprintf($user->lang['RETURN_INDEX'], '', ''); trigger_error($message); } @@ -474,4 +504,22 @@ class ucp_register $this->tpl_name = 'ucp_register'; $this->page_title = 'UCP_REGISTRATION'; } + + protected function get_login_link_data_array() + { + global $request; + + $var_names = $request->variable_names(phpbb_request_interface::POST); + $login_link_data = array(); + + foreach ($var_names as $var_name) + { + if (strpos($var_name, 'login_link_') === 0) + { + $login_link_data[$var_name] = $request->variable($var_name, '', false, phpbb_request_interface::POST); + } + } + + return $login_link_data; + } } -- cgit v1.2.1 From 3b19d5c1984c26a137013f0c60a45001321bfa88 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 31 Jul 2013 14:46:31 -0400 Subject: [feature/oauth] Fix errors on ucp_login_link PHPBB3-11673 --- phpBB/includes/ucp/ucp_login_link.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_login_link.php b/phpBB/includes/ucp/ucp_login_link.php index e60628e3c1..9f2fa6330a 100644 --- a/phpBB/includes/ucp/ucp_login_link.php +++ b/phpBB/includes/ucp/ucp_login_link.php @@ -28,6 +28,7 @@ class ucp_login_link function main($id, $mode) { global $config, $phpbb_container, $request, $template, $user; + global $phpbb_root_path, $phpEx; // Initialize necessary variables $login_error = null; @@ -94,7 +95,7 @@ class ucp_login_link 'LOGIN_LINK_ERROR' => $login_link_error, 'PASSWORD_CREDENTIAL' => 'login_password', 'USERNAME_CREDENTIAL' => 'login_username', - 'S_HIDDEN_FIELDS' => $this->get_hidden_fields(), + 'S_HIDDEN_FIELDS' => $this->get_hidden_fields($data), // Registration elements 'REGISTER_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'), @@ -108,10 +109,8 @@ class ucp_login_link $this->page_title = 'UCP_LOGIN_LINK'; } - protected function get_register_hidden_fields($data) + protected function get_hidden_fields($data) { - global $config, $phpbb_root_path, $phpEx, $request; - $fields = array(); foreach ($data as $key => $value) @@ -119,7 +118,7 @@ class ucp_login_link $fields['login_link_' . $key] = $value; } - return build_hidden_fields($s_hidden_fields); + return build_hidden_fields($fields); } protected function get_login_link_data_array() -- cgit v1.2.1 From aa80ac44a4f4f84d0fc41fa0218cc7d7140c3df0 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 31 Jul 2013 14:54:16 -0400 Subject: [feature/oauth] Login_link works with ucp_register now PHPBB3-11673 --- phpBB/includes/ucp/ucp_register.php | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index d52e172ec2..8400e98630 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -81,6 +81,7 @@ 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(); @@ -91,13 +92,13 @@ class ucp_register $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($data); + $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, $login_link_data); + $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'])) @@ -105,9 +106,9 @@ class ucp_register $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' => $change_lang, - ); + )); // If we change the language, we want to pass on some more possible parameter. if ($change_lang) @@ -433,10 +434,10 @@ class ucp_register } } - $s_hidden_fields = array( + $s_hidden_fields = array_merge($s_hidden_fields, array( 'agreed' => 'true', 'change_lang' => 0, - ); + )); if ($config['coppa_enable']) { @@ -516,10 +517,23 @@ class ucp_register { if (strpos($var_name, 'login_link_') === 0) { - $login_link_data[$var_name] = $request->variable($var_name, '', false, phpbb_request_interface::POST); + $key_name = str_replace('login_link_', '', $var_name); + $login_link_data[$key_name] = $request->variable($var_name, '', false, phpbb_request_interface::POST); } } return $login_link_data; } + + 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; + } } -- cgit v1.2.1 From 3264a7ece5cd4b964b854d6d3a1af044e2e70282 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 31 Jul 2013 16:33:54 -0400 Subject: [feature/oauth] Attempt to fix postgres issue PHPBB3-11673 --- phpBB/develop/create_schema_files.php | 2 +- phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index a722a88ff3..b634c236b0 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -928,7 +928,7 @@ function get_schema_struct() 'user_id' => array('UINT', 0), // phpbb_users.user_id 'session_id' => array('CHAR:32', ''), // phpbb_sessions.session_id used only when user_id not set 'provider' => array('VCHAR', ''), // Name of the OAuth provider - 'oauth_token' => array('TEXT_UNI', ''), // Serialized token + 'oauth_token' => array('MTEXT', ''), // Serialized token ), 'KEYS' => array( 'user_id' => array('INDEX', 'user_id'), diff --git a/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php b/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php index 5e3fa919e8..07541c7eac 100644 --- a/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php +++ b/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php @@ -23,7 +23,7 @@ class phpbb_db_migration_data_310_auth_provider_oauth extends phpbb_db_migration 'user_id' => array('UINT', 0), // phpbb_users.user_id 'session_id' => array('CHAR:32', ''), // phpbb_sessions.session_id used only when user_id not set 'provider' => array('VCHAR', ''), // Name of the OAuth provider - 'oauth_token' => array('TEXT_UNI'), // Serialized token + 'oauth_token' => array('MTEXT', ''), // Serialized token ), 'KEYS' => array( 'user_id' => array('INDEX', 'user_id'), -- cgit v1.2.1 From c33f97038675c7ca79c8cbb0ece08c989f411c9b Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 31 Jul 2013 16:50:19 -0400 Subject: [feature/oauth] Forgot to update schema files PHPBB3-11673 --- phpBB/install/schemas/firebird_schema.sql | 2 +- phpBB/install/schemas/mssql_schema.sql | 4 ++-- phpBB/install/schemas/mysql_40_schema.sql | 2 +- phpBB/install/schemas/mysql_41_schema.sql | 2 +- phpBB/install/schemas/postgres_schema.sql | 2 +- phpBB/install/schemas/sqlite_schema.sql | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) (limited to 'phpBB') diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index ce9be26e68..1e47008d73 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -133,7 +133,7 @@ CREATE TABLE phpbb_oauth_tokens ( user_id INTEGER DEFAULT 0 NOT NULL, session_id CHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, provider VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - oauth_token BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL + oauth_token BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL );; CREATE INDEX phpbb_oauth_tokens_user_id ON phpbb_oauth_tokens(user_id);; diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 94cfa98784..922313236e 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -173,8 +173,8 @@ CREATE TABLE [phpbb_oauth_tokens] ( [user_id] [int] DEFAULT (0) NOT NULL , [session_id] [char] (32) DEFAULT ('') NOT NULL , [provider] [varchar] (255) DEFAULT ('') NOT NULL , - [oauth_token] [varchar] (4000) DEFAULT ('') NOT NULL -) ON [PRIMARY] + [oauth_token] [text] DEFAULT ('') NOT NULL +) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO CREATE INDEX [user_id] ON [phpbb_oauth_tokens]([user_id]) ON [PRIMARY] diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index fe09756b1e..e07a768387 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -95,7 +95,7 @@ CREATE TABLE phpbb_oauth_tokens ( user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, session_id binary(32) DEFAULT '' NOT NULL, provider varbinary(255) DEFAULT '' NOT NULL, - oauth_token blob NOT NULL, + oauth_token mediumblob NOT NULL, KEY user_id (user_id), KEY provider (provider) ); diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index a385010f43..d3ed1ee15e 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -95,7 +95,7 @@ CREATE TABLE phpbb_oauth_tokens ( user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, session_id char(32) DEFAULT '' NOT NULL, provider varchar(255) DEFAULT '' NOT NULL, - oauth_token text NOT NULL, + oauth_token mediumtext NOT NULL, KEY user_id (user_id), KEY provider (provider) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index f64f4981d5..14435898eb 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -195,7 +195,7 @@ CREATE TABLE phpbb_oauth_tokens ( user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), session_id char(32) DEFAULT '' NOT NULL, provider varchar(255) DEFAULT '' NOT NULL, - oauth_token varchar(4000) DEFAULT '' NOT NULL + oauth_token TEXT DEFAULT '' NOT NULL ); CREATE INDEX phpbb_oauth_tokens_user_id ON phpbb_oauth_tokens (user_id); diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 54f3a132ef..de88900f06 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -94,7 +94,7 @@ CREATE TABLE phpbb_oauth_tokens ( user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', session_id char(32) NOT NULL DEFAULT '', provider varchar(255) NOT NULL DEFAULT '', - oauth_token text(65535) NOT NULL DEFAULT '' + oauth_token mediumtext(16777215) NOT NULL DEFAULT '' ); CREATE INDEX phpbb_oauth_tokens_user_id ON phpbb_oauth_tokens (user_id); -- cgit v1.2.1 From abee7760182f010dcd92b95c4c14c99a39798c5f Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 1 Aug 2013 21:30:36 -0400 Subject: [feature/oauth] Clean up oauth.php PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index cfeee94439..8979f413b5 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -129,8 +129,6 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base // Temporary workaround for only having one authentication provider available if (!$this->request->is_set('oauth_service')) { - // TODO: Remove before merging - global $phpbb_root_path, $phpEx; $provider = new phpbb_auth_provider_db($this->db, $this->config, $this->request, $this->user, $phpbb_root_path, $phpEx); return $provider->login($username, $password); } @@ -151,7 +149,8 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base $service_credentials = $this->service_providers[$service_name]->get_service_credentials(); $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_token_storage_table); - $service = $this->get_service($service_name_original, $storage, $service_credentials, $this->service_providers[$service_name]->get_auth_scope()); + $query = 'mode=login&login=external&oauth_service=' . $service_name; + $service = $this->get_service($service_name_original, $storage, $service_credentials, $this->service_providers[$service_name]->get_auth_scope(), $query); if ($this->request->is_set('code', phpbb_request_interface::GET)) { @@ -215,39 +214,45 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base /** * Returns the cached current_uri object or creates and caches it if it is - * not already created + * not already created. In each case the query string is updated based on + * the $query parameter. * - * @param string $service_name The name of the service + * @param string $service_name The name of the service + * @param string $query The query string of the current_uri + * used in redirects * @return \OAuth\Common\Http\Uri\UriInterface */ - protected function get_current_uri($service_name) + protected function get_current_uri($service_name, $query) { if ($this->current_uri) { + $this->current_uri->setQuery($query); return $this->current_uri; } $uri_factory = new \OAuth\Common\Http\Uri\UriFactory(); $current_uri = $uri_factory->createFromSuperGlobalArray($this->request->get_super_global(phpbb_request_interface::SERVER)); - $current_uri->setQuery('mode=login&login=external&oauth_service=' . $service_name); + $current_uri->setQuery($query); $this->current_uri = $current_uri; return $current_uri; } /** - * Returns the cached service object or creates a new one + * Returns a new service object * * @param string $service_name The name of the service * @param phpbb_auth_oauth_token_storage $storage * @param array $service_credentials {@see phpbb_auth_provider_oauth::get_service_credentials} * @param array $scope The scope of the request against * the api. + * @param string $query The query string of the + * current_uri used in redirection * @return \OAuth\Common\Service\ServiceInterface */ - protected function get_service($service_name, phpbb_auth_provider_oauth_token_storage $storage, array $service_credentials, array $scopes = array()) + protected function get_service($service_name, phpbb_auth_provider_oauth_token_storage $storage, array $service_credentials, array $scopes = array(), $query) { - $current_uri = $this->get_current_uri($service_name); + $current_uri = $this->get_current_uri($service_name, $query); // Setup the credentials for the requests $credentials = new Credentials( @@ -390,11 +395,10 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base } // Prepare for an authentication request - $this->get_current_uri(strtolower($link_data['oauth_service'])); - $this->current_uri->setQuery('mode=login_link&login_link_oauth_service=' . $service_name); $service_credentials = $this->service_providers[$service_name]->get_service_credentials(); $scopes = $this->service_providers[$service_name]->get_auth_scope(); - $service = $this->get_service(strtolower($link_data['oauth_service']), $storage, $service_credentials, $scopes); + $query = 'mode=login_link&login_link_oauth_service=' . $service_name; + $service = $this->get_service(strtolower($link_data['oauth_service']), $storage, $service_credentials, $scopes, $query); $this->service_providers[$service_name]->set_external_service_provider($service); // The user has already authenticated successfully, request to authenticate again -- cgit v1.2.1 From abe9f27723fdc979069082dbe6af3c8a0aceace6 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 1 Aug 2013 21:34:50 -0400 Subject: [feature/oauth] Clean up OAuth services PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/service/base.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/service/base.php b/phpBB/phpbb/auth/provider/oauth/service/base.php index ccfe57c8e2..1eb49b4265 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/base.php +++ b/phpBB/phpbb/auth/provider/oauth/service/base.php @@ -16,7 +16,7 @@ if (!defined('IN_PHPBB')) } /** -* Bitly OAuth service +* Base OAuth abstract class that all OAuth services should implement * * @package auth */ -- cgit v1.2.1 From 245e71e4e20b8d4ec80fc5e059dc12db51d10651 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Fri, 2 Aug 2013 14:05:09 -0400 Subject: [feature/oauth] Add get_login_data to the auth_provider_interface PHPBB3-11673 --- phpBB/includes/functions.php | 20 ++++++++++++++++++++ phpBB/phpbb/auth/provider/base.php | 8 ++++++++ phpBB/phpbb/auth/provider/interface.php | 21 +++++++++++++++++++++ phpBB/phpbb/auth/provider/oauth/oauth.php | 4 +--- 4 files changed, 50 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 02cdfd7ed1..79391aba56 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3367,6 +3367,26 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa $s_hidden_fields['credential'] = $credential; } + $auth_provider = $phpbb_container->get('auth.provider.' . $config['auth_method']); + + $auth_provider_data = $auth_provider->get_login_data(); + if ($auth_provider_data) + { + if (isset($auth_provider_data['VARS'])) + { + $template->assign_vars($auth_provider_data['VARS']); + } + + if (isset($auth_provider_data['BLOCK_VAR_NAME'])) + { + $template->assign_block_vars($auth_provider_data['BLOCK_VAR_NAME'], $auth_provider_data['BLOCK_VARS']); + } + + $template->assign_vars(array( + 'PROVIDER_TEMPLATE_FILE' => $auth_provider_data['TEMPLATE_FILE'], + )); + } + $oauth_login = ($config['auth_method'] == 'oauth') ? true : false; if ($oauth_login) diff --git a/phpBB/phpbb/auth/provider/base.php b/phpBB/phpbb/auth/provider/base.php index ca1c635b15..ae1daba82b 100644 --- a/phpBB/phpbb/auth/provider/base.php +++ b/phpBB/phpbb/auth/provider/base.php @@ -54,6 +54,14 @@ abstract class phpbb_auth_provider_base implements phpbb_auth_provider_interface return; } + /** + * {@inheritdoc} + */ + public function get_login_data() + { + return; + } + /** * {@inheritdoc} */ diff --git a/phpBB/phpbb/auth/provider/interface.php b/phpBB/phpbb/auth/provider/interface.php index fd3fa7d879..21526fd858 100644 --- a/phpBB/phpbb/auth/provider/interface.php +++ b/phpBB/phpbb/auth/provider/interface.php @@ -106,6 +106,27 @@ interface phpbb_auth_provider_interface */ public function get_acp_template($new_config); + /** + * Returns an array of data necessary to build custom elements on the login + * form. + * + * @return array|null If this function is not implemented on an auth + * provider then it returns null. If it is implemented + * it will return an array of up to four elements of + * which only 'TEMPLATE_FILE'. If 'BLOCK_VAR_NAME' is + * present then 'BLOCK_VARS' must also be present in + * the array. The fourth element 'VARS' is also + * optional. The array, with all four elements present + * looks like the following: + * array( + * 'TEMPLATE_FILE' => string, + * 'BLOCK_VAR_NAME' => string, + * 'BLOCK_VARS' => array(...), + * 'VARS' => array(...), + * ) + */ + public function get_login_data(); + /** * Performs additional actions during logout. * diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 8979f413b5..62024ff094 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -274,9 +274,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base } /** - * Returns an array of login data for all enabled OAuth services. - * - * @return array + * {@inheritdoc} */ public function get_login_data() { -- cgit v1.2.1 From 1ae2283b348d6fef1f9e90a49e2a25914465585e Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Fri, 2 Aug 2013 14:21:07 -0400 Subject: [feature/oauth] Finish updating interface and related code PHPBB3-11673 --- phpBB/includes/functions.php | 19 ++++--------------- phpBB/phpbb/auth/provider/oauth/oauth.php | 8 ++++++-- phpBB/styles/prosilver/template/login_body.html | 13 ++++--------- phpBB/styles/prosilver/template/login_body_oauth.html | 8 ++++++++ 4 files changed, 22 insertions(+), 26 deletions(-) create mode 100644 phpBB/styles/prosilver/template/login_body_oauth.html (limited to 'phpBB') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 79391aba56..5849a21013 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3379,7 +3379,10 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa if (isset($auth_provider_data['BLOCK_VAR_NAME'])) { - $template->assign_block_vars($auth_provider_data['BLOCK_VAR_NAME'], $auth_provider_data['BLOCK_VARS']); + foreach ($auth_provider_data['BLOCK_VARS'] as $block_vars) + { + $template->assign_block_vars($auth_provider_data['BLOCK_VAR_NAME'], $block_vars); + } } $template->assign_vars(array( @@ -3387,26 +3390,12 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa )); } - $oauth_login = ($config['auth_method'] == 'oauth') ? true : false; - - if ($oauth_login) - { - $auth_provider = $phpbb_container->get('auth.provider.oauth'); - $oauth_box_data = $auth_provider->get_login_data(); - foreach ($oauth_box_data as $data) - { - $template->assign_block_vars('oauth', $data); - } - } - $s_hidden_fields = build_hidden_fields($s_hidden_fields); $template->assign_vars(array( 'LOGIN_ERROR' => $err, 'LOGIN_EXPLAIN' => $l_explain, - 'OAUTH_LOGIN' => $oauth_login, - 'U_SEND_PASSWORD' => ($config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=sendpassword') : '', 'U_RESEND_ACTIVATION' => ($config['require_activation'] == USER_ACTIVATION_SELF && $config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=resend_act') : '', 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'), diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 62024ff094..1cc19d143e 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -278,7 +278,11 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base */ public function get_login_data() { - $login_data = array(); + $login_data = array( + 'TEMPLATE_FILE' => 'login_body_oauth.html', + 'BLOCK_VAR_NAME' => 'oauth', + 'BLOCK_VARS' => array(), + ); foreach ($this->service_providers as $service_name => $service_provider) { @@ -288,7 +292,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base { $actual_name = str_replace('auth.provider.oauth.service.', '', $service_name); $redirect_url = build_url(false) . '&login=external&oauth_service=' . $actual_name; - $login_data[$service_name] = array( + $login_data['BLOCK_VARS'][$service_name] = array( 'REDIRECT_URL' => redirect($redirect_url, true), 'SERVICE_NAME' => $this->user->lang['AUTH_PROVIDER_OAUTH_SERVICE_' . strtoupper($actual_name)], ); diff --git a/phpBB/styles/prosilver/template/login_body.html b/phpBB/styles/prosilver/template/login_body.html index 64b3915a1b..e00e5d7a67 100644 --- a/phpBB/styles/prosilver/template/login_body.html +++ b/phpBB/styles/prosilver/template/login_body.html @@ -46,16 +46,11 @@
{S_HIDDEN_FIELDS}
-
+
-
- -
-
 
-
{oauth.SERVICE_NAME}
-
- -
+ + + diff --git a/phpBB/styles/prosilver/template/login_body_oauth.html b/phpBB/styles/prosilver/template/login_body_oauth.html new file mode 100644 index 0000000000..eb6c627c6f --- /dev/null +++ b/phpBB/styles/prosilver/template/login_body_oauth.html @@ -0,0 +1,8 @@ +
+ +
+
 
+
{oauth.SERVICE_NAME}
+
+ +
\ No newline at end of file -- cgit v1.2.1 From 2222f3f38048b004b353f0f346cee1d1a0eafd37 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Fri, 2 Aug 2013 14:23:18 -0400 Subject: [feature/oauth] Fix error caused by previous change in OAuth PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 1cc19d143e..3528c0b83f 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -149,7 +149,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base $service_credentials = $this->service_providers[$service_name]->get_service_credentials(); $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_token_storage_table); - $query = 'mode=login&login=external&oauth_service=' . $service_name; + $query = 'mode=login&login=external&oauth_service=' . $service_name_original; $service = $this->get_service($service_name_original, $storage, $service_credentials, $this->service_providers[$service_name]->get_auth_scope(), $query); if ($this->request->is_set('code', phpbb_request_interface::GET)) @@ -399,7 +399,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base // Prepare for an authentication request $service_credentials = $this->service_providers[$service_name]->get_service_credentials(); $scopes = $this->service_providers[$service_name]->get_auth_scope(); - $query = 'mode=login_link&login_link_oauth_service=' . $service_name; + $query = 'mode=login_link&login_link_oauth_service=' . strtolower($link_data['oauth_service']); $service = $this->get_service(strtolower($link_data['oauth_service']), $storage, $service_credentials, $scopes, $query); $this->service_providers[$service_name]->set_external_service_provider($service); -- cgit v1.2.1 From e16dd958e351c39371db943fec359677c950c9ec Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Fri, 2 Aug 2013 14:31:12 -0400 Subject: [feature/oauth] OAuth clear tokens on logout PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 3528c0b83f..786caf5463 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -419,4 +419,18 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base // Update token storage to store the user_id $storage->set_user_id($link_data['user_id']); } + + /** + * {@inheritdoc} + */ + public function logout($data, $new_session) + { + // Clear all tokens belonging to the user + $sql = 'DELETE FROM ' . $this->auth_provider_oauth_token_storage_table . " + WHERE session_id = '" . $this->db->sql_escape($this->user->session_id) . "' + AND user_id = " . (int) $this->user->data['user_id']; + $this->db->sql_query($sql); + + return; + } } -- cgit v1.2.1 From 3cbb97316066b606548af5d24b4fe2199533cffe Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Fri, 2 Aug 2013 14:37:15 -0400 Subject: [feature/oauth] Pass users_table as parameter to OAuth in construct PHPBB3-11673 --- phpBB/config/auth_providers.yml | 1 + phpBB/phpbb/auth/provider/oauth/oauth.php | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/config/auth_providers.yml b/phpBB/config/auth_providers.yml index 393c2a4229..bad6be9880 100644 --- a/phpBB/config/auth_providers.yml +++ b/phpBB/config/auth_providers.yml @@ -45,6 +45,7 @@ services: - %tables.auth_provider_oauth_token_storage% - %tables.auth_provider_oauth_account_assoc% - @auth.provider.oauth.service_collection + - %tables.users% tags: - { name: auth.provider } auth.provider.oauth.service_collection: diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 786caf5463..4973cde349 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -74,6 +74,13 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base */ protected $service_providers; + /** + * Users table + * + * @var string + */ + protected $users_table; + /** * Cached current uri object * @@ -91,8 +98,9 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base * @param string $auth_provider_oauth_token_storage_table * @param string $auth_provider_oauth_token_account_assoc * @param phpbb_di_service_collection $service_providers Contains phpbb_auth_provider_oauth_service_interface + * @param string $users)table */ - public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_request $request, phpbb_user $user, $auth_provider_oauth_token_storage_table, $auth_provider_oauth_token_account_assoc, phpbb_di_service_collection $service_providers) + public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_request $request, phpbb_user $user, $auth_provider_oauth_token_storage_table, $auth_provider_oauth_token_account_assoc, phpbb_di_service_collection $service_providers, $users_table) { $this->db = $db; $this->config = $config; @@ -101,6 +109,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base $this->auth_provider_oauth_token_storage_table = $auth_provider_oauth_token_storage_table; $this->auth_provider_oauth_token_account_assoc = $auth_provider_oauth_token_account_assoc; $this->service_providers = $service_providers; + $this->users_table = $users_table; } /** @@ -184,7 +193,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base // Retrieve the user's account $sql = 'SELECT user_id, username, user_password, user_passchg, user_pass_convert, user_email, user_type, user_login_attempts - FROM ' . USERS_TABLE . " + FROM ' . $this->users_table . " WHERE user_id = '" . $this->db->sql_escape($row['user_id']) . "'"; $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); -- cgit v1.2.1 From 520027c8b7975e22efd2f687dc14587a01332103 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 4 Aug 2013 12:06:26 +0100 Subject: [ticket/11637] generate_text_for_display on search.php sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11639 --- phpBB/search.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'phpBB') diff --git a/phpBB/search.php b/phpBB/search.php index 7d20d8d4a2..d0c9df9451 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -962,14 +962,8 @@ if ($keywords || $author || $author_id || $search_id || $submit) } else { - // Second parse bbcode here - if ($row['bbcode_bitfield']) - { - $bbcode->bbcode_second_pass($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield']); - } - - $row['post_text'] = bbcode_nl2br($row['post_text']); - $row['post_text'] = smiley_text($row['post_text']); + $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; + $row['post_text'] = generate_text_for_display($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, false); if (!empty($attachments[$row['post_id']])) { -- cgit v1.2.1 From baa3a750c4cd2112202c40b39d1f3fdf5b05bdb1 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 5 Aug 2013 15:34:26 -0400 Subject: [feature/oauth] Start general auth linking page PHPBB3-11673 --- phpBB/includes/ucp/ucp_auth_link.php | 27 ++++++++++++++++++++++ phpBB/language/en/ucp.php | 1 + phpBB/styles/prosilver/template/ucp_auth_link.html | 3 +++ 3 files changed, 31 insertions(+) create mode 100644 phpBB/includes/ucp/ucp_auth_link.php create mode 100644 phpBB/styles/prosilver/template/ucp_auth_link.html (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_auth_link.php b/phpBB/includes/ucp/ucp_auth_link.php new file mode 100644 index 0000000000..266273cff8 --- /dev/null +++ b/phpBB/includes/ucp/ucp_auth_link.php @@ -0,0 +1,27 @@ +tpl_name = 'ucp_auth_link'; + $this->page_title = 'UCP_AUTH_LINK'; + } +} diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index 101fc7663a..a25fb54c8c 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -479,6 +479,7 @@ $lang = array_merge($lang, array( 'UCP_ADMIN_ACTIVATE' => 'Please note that you will need to enter a valid email address before your account is activated. The administrator will review your account and if approved you will receive an email at the address you specified.', 'UCP_AIM' => 'AOL Instant Messenger', 'UCP_ATTACHMENTS' => 'Attachments', + 'UCP_AUTH_LINK' => 'Link an external account', 'UCP_COPPA_BEFORE' => 'Before %s', 'UCP_COPPA_ON_AFTER' => 'On or after %s', 'UCP_EMAIL_ACTIVATE' => 'Please note that you will need to enter a valid email address before your account is activated. You will receive an email at the address you provide that contains an account activation link.', diff --git a/phpBB/styles/prosilver/template/ucp_auth_link.html b/phpBB/styles/prosilver/template/ucp_auth_link.html new file mode 100644 index 0000000000..a129e36c2c --- /dev/null +++ b/phpBB/styles/prosilver/template/ucp_auth_link.html @@ -0,0 +1,3 @@ + + + -- cgit v1.2.1 From 4683c37682541f73deca1f1476daf8c24f6962d6 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 5 Aug 2013 15:38:58 -0400 Subject: [feature/oauth] Forgot to have login_link be "in login" in ucp PHPBB3-11673 --- phpBB/includes/ucp/info/ucp_auth_link.php | 34 +++++++++++++++++++++++++++++++ phpBB/language/en/ucp.php | 3 ++- phpBB/ucp.php | 2 +- 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 phpBB/includes/ucp/info/ucp_auth_link.php (limited to 'phpBB') 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..c5cd997af4 --- /dev/null +++ b/phpBB/includes/ucp/info/ucp_auth_link.php @@ -0,0 +1,34 @@ + '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_MAIN')), + ), + ); + } + + function install() + { + } + + function uninstall() + { + } +} diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index a25fb54c8c..993e5b56f8 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -479,7 +479,8 @@ $lang = array_merge($lang, array( 'UCP_ADMIN_ACTIVATE' => 'Please note that you will need to enter a valid email address before your account is activated. The administrator will review your account and if approved you will receive an email at the address you specified.', 'UCP_AIM' => 'AOL Instant Messenger', 'UCP_ATTACHMENTS' => 'Attachments', - 'UCP_AUTH_LINK' => 'Link an external account', + 'UCP_AUTH_LINK' => 'External accounts', + 'UCP_AUTH_LINK_MANAGE' => 'Manage external accounts', 'UCP_COPPA_BEFORE' => 'Before %s', 'UCP_COPPA_ON_AFTER' => 'On or after %s', 'UCP_EMAIL_ACTIVATE' => 'Please note that you will need to enter a valid email address before your account is activated. You will receive an email at the address you provide that contains an account activation link.', diff --git a/phpBB/ucp.php b/phpBB/ucp.php index d69d938038..f1f8f2a829 100644 --- a/phpBB/ucp.php +++ b/phpBB/ucp.php @@ -21,7 +21,7 @@ require($phpbb_root_path . 'includes/functions_module.' . $phpEx); $id = request_var('i', ''); $mode = request_var('mode', ''); -if (in_array($mode, array('login', 'logout', 'confirm', 'sendpassword', 'activate'))) +if (in_array($mode, array('login', 'login_link', 'logout', 'confirm', 'sendpassword', 'activate'))) { define('IN_LOGIN', true); } -- cgit v1.2.1 From 6be6de2b29cb7cbcf8b882e0f11cb0b02232aff9 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 7 Aug 2013 21:40:16 -0400 Subject: [feature/oauth] Migration update for new ucp module PHPBB3-11673 --- .../phpbb/db/migration/data/310/auth_provider_oauth.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php b/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php index 07541c7eac..8706d14798 100644 --- a/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php +++ b/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php @@ -49,8 +49,23 @@ class phpbb_db_migration_data_310_auth_provider_oauth extends phpbb_db_migration { return array( 'drop_tables' => array( - $this->table_prefix . 'auth_provider_oauth', + $this->table_prefix . 'oauth_tokens', + $this->table_prefix . 'oauth_accounts', ), ); } + + public function update_data() + { + return array( + array('module.add', array( + 'ucp', + 'UCP_AUTH_LINK', + array( + 'module_basename' => 'ucp_auth_link', + 'modes' => array('auth_link'), + ), + )), + ); + } } -- cgit v1.2.1 From 786da260c0e5f5c87b6b617fcb35d43141c75d50 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Fri, 9 Aug 2013 04:36:49 -0400 Subject: [feature/oauth] Fix ucp_auth_link headers/footers PHPBB3-11673 --- phpBB/styles/prosilver/template/ucp_auth_link.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/styles/prosilver/template/ucp_auth_link.html b/phpBB/styles/prosilver/template/ucp_auth_link.html index a129e36c2c..12353f31bd 100644 --- a/phpBB/styles/prosilver/template/ucp_auth_link.html +++ b/phpBB/styles/prosilver/template/ucp_auth_link.html @@ -1,3 +1,3 @@ - + - + -- cgit v1.2.1 From b5255d42b56b1d0d14bcd9a70218689932065ce6 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Fri, 9 Aug 2013 04:38:38 -0400 Subject: [feature/oauth] Default auth_link into UCP_PROFILE not UCP_MAIN PHPBB3-11673 --- phpBB/includes/ucp/info/ucp_auth_link.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/info/ucp_auth_link.php b/phpBB/includes/ucp/info/ucp_auth_link.php index c5cd997af4..ee88b15ea8 100644 --- a/phpBB/includes/ucp/info/ucp_auth_link.php +++ b/phpBB/includes/ucp/info/ucp_auth_link.php @@ -19,7 +19,7 @@ class ucp_auth_link_info 'title' => 'UCP_AUTH_LINK', 'version' => '1.0.0', 'modes' => array( - 'auth_link' => array('title' => 'UCP_AUTH_LINK_MANAGE', 'auth' => '', 'cat' => array('UCP_MAIN')), + 'auth_link' => array('title' => 'UCP_AUTH_LINK_MANAGE', 'auth' => '', 'cat' => array('UCP_PROFILE')), ), ); } -- cgit v1.2.1 From deb62d51fe4e06e52fbc4042b692071bcd8f9d39 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Fri, 9 Aug 2013 05:12:41 -0400 Subject: [feature/oauth] Start building the template PHPBB3-11673 --- phpBB/includes/ucp/ucp_auth_link.php | 28 ++++++++++++++++++++++ phpBB/language/en/ucp.php | 1 + phpBB/styles/prosilver/template/ucp_auth_link.html | 8 +++++++ 3 files changed, 37 insertions(+) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_auth_link.php b/phpBB/includes/ucp/ucp_auth_link.php index 266273cff8..6bf74d4fbf 100644 --- a/phpBB/includes/ucp/ucp_auth_link.php +++ b/phpBB/includes/ucp/ucp_auth_link.php @@ -21,6 +21,34 @@ class ucp_auth_link public function main($id, $mode) { + global $template, $phpbb_container; + + $error = array(); + $s_hidden_fields = array(); + add_form_key('ucp_auth_link'); + + $submit = $request->variable('submit', false, false, phpbb_request_interface::POST); + + if ($submit) + { + if (!check_form_key('ucp_reg_details')) + { + $error[] = 'FORM_INVALID'; + } + + if (!sizeof($error)) + { + + } + } + + $s_hidden_fields = build_hidden_fields($s_hidden_fields); + + $template->assign_vars(array( + '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/language/en/ucp.php b/phpBB/language/en/ucp.php index 993e5b56f8..4798b1e81c 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -481,6 +481,7 @@ $lang = array_merge($lang, array( 'UCP_ATTACHMENTS' => 'Attachments', 'UCP_AUTH_LINK' => 'External accounts', 'UCP_AUTH_LINK_MANAGE' => 'Manage external accounts', + 'UCP_AUTH_LINK_TITLE' => 'Manage Your External Accounts', 'UCP_COPPA_BEFORE' => 'Before %s', 'UCP_COPPA_ON_AFTER' => 'On or after %s', 'UCP_EMAIL_ACTIVATE' => 'Please note that you will need to enter a valid email address before your account is activated. You will receive an email at the address you provide that contains an account activation link.', diff --git a/phpBB/styles/prosilver/template/ucp_auth_link.html b/phpBB/styles/prosilver/template/ucp_auth_link.html index 12353f31bd..b521518bf3 100644 --- a/phpBB/styles/prosilver/template/ucp_auth_link.html +++ b/phpBB/styles/prosilver/template/ucp_auth_link.html @@ -1,3 +1,11 @@ +

{L_UCP_AUTH_LINK_TITLE}

+ +
+ +{S_HIDDEN_FIELDS} +{S_FORM_TOKEN} +
+ -- cgit v1.2.1 From 0b80aaf2178e5a40f9429ce972c490f6067ef114 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Fri, 9 Aug 2013 05:16:39 -0400 Subject: [feature/oauth] Add method to return necessary data for auth_link PHPBB3-11673 --- phpBB/includes/ucp/ucp_auth_link.php | 11 ++++++++++- phpBB/phpbb/auth/provider/base.php | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_auth_link.php b/phpBB/includes/ucp/ucp_auth_link.php index 6bf74d4fbf..c1d97c8cf8 100644 --- a/phpBB/includes/ucp/ucp_auth_link.php +++ b/phpBB/includes/ucp/ucp_auth_link.php @@ -21,7 +21,16 @@ class ucp_auth_link public function main($id, $mode) { - global $template, $phpbb_container; + global $config, $request, $template, $phpbb_container; + + $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) + { + // does not support this page, throw error? + } $error = array(); $s_hidden_fields = array(); diff --git a/phpBB/phpbb/auth/provider/base.php b/phpBB/phpbb/auth/provider/base.php index ae1daba82b..2f1bf8f601 100644 --- a/phpBB/phpbb/auth/provider/base.php +++ b/phpBB/phpbb/auth/provider/base.php @@ -62,6 +62,14 @@ abstract class phpbb_auth_provider_base implements phpbb_auth_provider_interface return; } + /** + * {@inheritdoc} + */ + public function get_auth_link_data() + { + return; + } + /** * {@inheritdoc} */ -- cgit v1.2.1 From 69cb2e4c603243f75fcfd288d0018390b763ce05 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Fri, 9 Aug 2013 05:26:44 -0400 Subject: [feature/oauth] More template work PHPBB3-11673 --- phpBB/includes/ucp/ucp_auth_link.php | 3 +++ phpBB/phpbb/auth/provider/oauth/oauth.php | 10 ++++++++++ phpBB/styles/prosilver/template/ucp_auth_link.html | 6 +----- phpBB/styles/prosilver/template/ucp_auth_link_oauth.html | 5 +++++ 4 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 phpBB/styles/prosilver/template/ucp_auth_link_oauth.html (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_auth_link.php b/phpBB/includes/ucp/ucp_auth_link.php index c1d97c8cf8..cb6d85d6b7 100644 --- a/phpBB/includes/ucp/ucp_auth_link.php +++ b/phpBB/includes/ucp/ucp_auth_link.php @@ -30,6 +30,7 @@ class ucp_auth_link if ($provider_data === null) { // does not support this page, throw error? + throw new Exception('TEMPORARY EXCEPTION'); } $error = array(); @@ -54,6 +55,8 @@ class ucp_auth_link $s_hidden_fields = build_hidden_fields($s_hidden_fields); $template->assign_vars(array( + 'PROVIDER_TEMPLATE_FILE' => $provider_data['TEMPLATE_FILE'], + 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_UCP_ACTION' => $this->u_action, )); diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 4973cde349..d27e40ca77 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -442,4 +442,14 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base return; } + + /** + * {@inheritdoc} + */ + public function get_auth_link_data() + { + return array( + 'TEMPLATE_FILE' => 'ucp_auth_link_oauth.html', + ); + } } diff --git a/phpBB/styles/prosilver/template/ucp_auth_link.html b/phpBB/styles/prosilver/template/ucp_auth_link.html index b521518bf3..5e5fc6d2f0 100644 --- a/phpBB/styles/prosilver/template/ucp_auth_link.html +++ b/phpBB/styles/prosilver/template/ucp_auth_link.html @@ -2,10 +2,6 @@

{L_UCP_AUTH_LINK_TITLE}

-
- -{S_HIDDEN_FIELDS} -{S_FORM_TOKEN} -
+ diff --git a/phpBB/styles/prosilver/template/ucp_auth_link_oauth.html b/phpBB/styles/prosilver/template/ucp_auth_link_oauth.html new file mode 100644 index 0000000000..ca13ff0ab6 --- /dev/null +++ b/phpBB/styles/prosilver/template/ucp_auth_link_oauth.html @@ -0,0 +1,5 @@ +
+ +{S_HIDDEN_FIELDS} +{S_FORM_TOKEN} +
\ No newline at end of file -- cgit v1.2.1 From 9a5363462b54cf137a1ec0149c0fa6cfbeca5e7c Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 11 Aug 2013 19:57:34 +0300 Subject: [ticket/11782] Change p.rules to p.post-notice in templates PHPBB3-11782 --- phpBB/styles/prosilver/template/mcp_post.html | 8 ++-- phpBB/styles/prosilver/template/mcp_topic.html | 20 +++++++--- .../prosilver/template/ucp_pm_viewmessage.html | 2 +- .../styles/prosilver/template/viewtopic_body.html | 43 ++++++++++++---------- 4 files changed, 43 insertions(+), 30 deletions(-) (limited to 'phpBB') diff --git a/phpBB/styles/prosilver/template/mcp_post.html b/phpBB/styles/prosilver/template/mcp_post.html index 4cdd62957c..7b2ace6792 100644 --- a/phpBB/styles/prosilver/template/mcp_post.html +++ b/phpBB/styles/prosilver/template/mcp_post.html @@ -14,7 +14,7 @@

{L_REPORT_REASON}{L_COLON} {REPORT_REASON_TITLE}

{L_REPORTED} {L_POST_BY_AUTHOR} {REPORTER_FULL} « {REPORT_DATE}

-

{L_REPORT_CLOSED}

+

{L_REPORT_CLOSED}

@@ -71,7 +71,7 @@
-

+

  @@ -82,7 +82,7 @@ -

+

  @@ -93,7 +93,7 @@ -

+

{REPORTED_IMG} {L_MESSAGE_REPORTED}

diff --git a/phpBB/styles/prosilver/template/mcp_topic.html b/phpBB/styles/prosilver/template/mcp_topic.html index 0fd5a9455f..bfe18579a6 100644 --- a/phpBB/styles/prosilver/template/mcp_topic.html +++ b/phpBB/styles/prosilver/template/mcp_topic.html @@ -101,11 +101,21 @@

{postrow.POST_SUBJECT}

{postrow.MINI_POST_IMG} {L_POSTED} {postrow.POST_DATE} {L_POST_BY_AUTHOR} {postrow.POST_AUTHOR_FULL} [ {L_POST_DETAILS} ]

- -

- {UNAPPROVED_IMG} {L_POST_UNAPPROVED}
- {DELETED_IMG} {L_POST_DELETED}
- {REPORTED_IMG} {L_POST_REPORTED} + +

+ {L_POST_UNAPPROVED} +

+ + + +

+ {L_POST_DELETED} +

+ + + +

+ {L_POST_REPORTED}

diff --git a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html index 4f2531d3a6..50e76f5b75 100644 --- a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html +++ b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html @@ -62,7 +62,7 @@ -
{L_DOWNLOAD_NOTICE}
+
{L_DOWNLOAD_NOTICE}
diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index c8a99b18e4..0f0961eba2 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -151,29 +151,32 @@

class="first"> {postrow.POST_SUBJECT}

{postrow.MINI_POST_IMG}{postrow.MINI_POST_IMG}{L_POST_BY_AUTHOR} {postrow.POST_AUTHOR_FULL} » {postrow.POST_DATE}

- + -

- - {UNAPPROVED_IMG} {L_POST_UNAPPROVED} - - - - {S_FORM_TOKEN} -
- - {DELETED_IMG} {L_POST_DELETED} - - - - {S_FORM_TOKEN} -
- - - {REPORTED_IMG} {L_POST_REPORTED} - +

+ {L_POST_UNAPPROVED} + + + + {S_FORM_TOKEN}

+ +
+

+ {L_POST_DELETED} + + + + {S_FORM_TOKEN} +

+
+ + + +

+ {L_POST_REPORTED} +

{postrow.MESSAGE}
-- cgit v1.2.1 From 788238d7a989951747307b15eaa2192253e81535 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 11 Aug 2013 20:00:41 +0300 Subject: [ticket/11782] Change p.rules to p.post-notice in CSS PHPBB3-11782 --- phpBB/styles/prosilver/theme/colours.css | 15 ++++++++++++++- phpBB/styles/prosilver/theme/common.css | 29 +++++++++++++++++------------ 2 files changed, 31 insertions(+), 13 deletions(-) (limited to 'phpBB') diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css index 5548905ede..7736371460 100644 --- a/phpBB/styles/prosilver/theme/colours.css +++ b/phpBB/styles/prosilver/theme/colours.css @@ -214,11 +214,24 @@ div.rules { color: #BC2A4D; } -p.rules { +p.post-notice { background-color: #ECD5D8; background-image: none; } +p.post-notice.deleted:before { + background-image: url("./images/icon_topic_deleted.png"); +} + +p.post-notice.unapproved:before { + background-image: url("./images/icon_topic_unapproved.gif"); +} + +p.post-notice.reported:before, p.post-notice.error:before { + background-image: url("./images/icon_topic_reported.gif"); +} + + /* -------------------------------------------------------------- Colours and backgrounds for links.css diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index a2b8034187..cdafc706df 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -685,23 +685,28 @@ div.rules ul, div.rules ol { margin-left: 20px; } -p.rules { - background-image: none; +p.post-notice { + position: relative; padding: 5px; + padding-left: 26px; + min-height: 14px; + margin-bottom: 1em; } -p.rules img { - vertical-align: middle; -} - -p.rules strong { - vertical-align: middle; - padding-top: 5px; +p.post-notice:before { + content: ''; + display: block; + position: absolute; + top: 0; + bottom: 0; + left: 0; + width: 28px; + background: transparent none 50% 50% no-repeat; + pointer-events: none; } -p.rules a { - vertical-align: middle; - clear: both; +form p.post-notice strong { + line-height: 20px; } #top { -- cgit v1.2.1 From c63901fcb59f3795023dc9ea2b35c616fa08b756 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 11 Aug 2013 20:01:15 +0300 Subject: [ticket/11782] RTL support for post notices PHPBB3-11782 --- phpBB/styles/prosilver/theme/bidi.css | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'phpBB') diff --git a/phpBB/styles/prosilver/theme/bidi.css b/phpBB/styles/prosilver/theme/bidi.css index a921805327..41a9874a18 100644 --- a/phpBB/styles/prosilver/theme/bidi.css +++ b/phpBB/styles/prosilver/theme/bidi.css @@ -371,6 +371,13 @@ float: right; } +.rtl p.post-notice:before { + left: auto; + right: 0; + padding-left: 5px; + padding-right: 26px; +} + /* Topic review panel ----------------------------------------*/ .rtl #topicreview { -- cgit v1.2.1 From 0b32a97c4711afccc77ff74b32cc0d0ff6b7d6bc Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 11 Aug 2013 20:10:33 +0300 Subject: [ticket/11782] Apply line-height correctly Apply line-height only to bolded elements inside post notices that are direct child elements of forms. PHPBB3-11782 --- phpBB/styles/prosilver/theme/common.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index cdafc706df..4a77dc78d0 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -705,7 +705,7 @@ p.post-notice:before { pointer-events: none; } -form p.post-notice strong { +form > p.post-notice strong { line-height: 20px; } -- cgit v1.2.1 From a479f919ff17bc96e55baf8c4b811ac4ec22d8f1 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 12 Aug 2013 12:53:10 -0400 Subject: [feature/oauth] Error handling on page PHPBB3-11673 --- phpBB/includes/ucp/ucp_auth_link.php | 26 ++++++++++++++++++---- phpBB/styles/prosilver/template/ucp_auth_link.html | 2 ++ 2 files changed, 24 insertions(+), 4 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_auth_link.php b/phpBB/includes/ucp/ucp_auth_link.php index cb6d85d6b7..cf92b5d58d 100644 --- a/phpBB/includes/ucp/ucp_auth_link.php +++ b/phpBB/includes/ucp/ucp_auth_link.php @@ -23,23 +23,23 @@ class ucp_auth_link { global $config, $request, $template, $phpbb_container; + $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) { - // does not support this page, throw error? - throw new Exception('TEMPORARY EXCEPTION'); + $error[] = 'UCP_AUTH_LINK_NOT_SUPPORTED'; } - $error = array(); $s_hidden_fields = array(); add_form_key('ucp_auth_link'); $submit = $request->variable('submit', false, false, phpbb_request_interface::POST); - if ($submit) + if (!sizeof($error) && $submit) { if (!check_form_key('ucp_reg_details')) { @@ -55,6 +55,8 @@ class ucp_auth_link $s_hidden_fields = build_hidden_fields($s_hidden_fields); $template->assign_vars(array( + 'ERROR' => $this->build_error_text($error), + 'PROVIDER_TEMPLATE_FILE' => $provider_data['TEMPLATE_FILE'], 'S_HIDDEN_FIELDS' => $s_hidden_fields, @@ -64,4 +66,20 @@ class ucp_auth_link $this->tpl_name = 'ucp_auth_link'; $this->page_title = 'UCP_AUTH_LINK'; } + + private function build_error_text(array $errors) + { + global $user; + + // Replace all errors that are language constants + foreach ($errors as $key => $error) + { + if (isset($user->lang[$error])) + { + $errors[$key] = $user->lang($error); + } + } + + return implode('
', $errors); + } } diff --git a/phpBB/styles/prosilver/template/ucp_auth_link.html b/phpBB/styles/prosilver/template/ucp_auth_link.html index 5e5fc6d2f0..8ba16c55c8 100644 --- a/phpBB/styles/prosilver/template/ucp_auth_link.html +++ b/phpBB/styles/prosilver/template/ucp_auth_link.html @@ -2,6 +2,8 @@

{L_UCP_AUTH_LINK_TITLE}

+
{ERROR}
+ -- cgit v1.2.1 From e04844c95f52c6da295d20bccc9530ee7e4b63f7 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 12 Aug 2013 13:18:00 -0400 Subject: [feature/oauth] Build OAuth data for ucp_auth_link PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 43 +++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index d27e40ca77..d0b5583d77 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -448,7 +448,50 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base */ public function get_auth_link_data() { + $block_vars = array(); + + // Get all external accounts tied to the current user + $data = array( + 'user_id' => $user->data['user_id'], + ); + $sql = 'SELECT oauth_provider_id, provider FROM ' . $this->auth_provider_oauth_token_account_assoc . ' + WHERE ' . $this->db->sql_build_array('SELECT', $data); + $result = $this->db->sql_query($sql); + $rows = $this->db->sql_fetchrowset($result); + $this->db->sql_freeresult($result); + + $oauth_user_ids = array(); + + if ($row !== false && !empty($rows)) + { + foreach ($row as $row) + { + $oauth_user_ids[$row['provider']] = $row['oauth_provider_id']; + } + } + unset($rows); + + foreach ($this->service_providers as $service_name => $service_provider) + { + // Only include data if the credentials are set + $credentials = $service_provider->get_service_credentials(); + if ($credentials['key'] && $credentials['secret']) + { + $actual_name = str_replace('auth.provider.oauth.service.', '', $service_name); + $redirect_url = build_url(false) . '&login=external&oauth_service=' . $actual_name; + + $block_vars[$service_name] = array( + 'REDIRECT_URL' => redirect($redirect_url, true), + 'SERVICE_NAME' => $this->user->lang['AUTH_PROVIDER_OAUTH_SERVICE_' . strtoupper($actual_name)], + 'UNIQUE_ID' => (isset($oauth_user_ids[$actual_name])) ? $oauth_user_ids[$actual_name] : null, + ); + } + } + return array( + 'BLOCK_VAR_NAME' => 'oauth', + 'BLOCK_VARS' => $block_vars, + 'TEMPLATE_FILE' => 'ucp_auth_link_oauth.html', ); } -- cgit v1.2.1 From 4003e077c170e2c9aebbf582cb08249d80d37a3d Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 12 Aug 2013 14:43:18 -0400 Subject: [feature/oauth] Get the OAuth template in place for ucp_auth_link PHPBB3-11673 --- phpBB/includes/ucp/ucp_auth_link.php | 13 +++++++++ phpBB/phpbb/auth/provider/oauth/oauth.php | 6 ++--- phpBB/styles/prosilver/template/ucp_auth_link.html | 8 ++++-- .../prosilver/template/ucp_auth_link_oauth.html | 31 +++++++++++++++++++--- 4 files changed, 49 insertions(+), 9 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_auth_link.php b/phpBB/includes/ucp/ucp_auth_link.php index cf92b5d58d..05896f93b0 100644 --- a/phpBB/includes/ucp/ucp_auth_link.php +++ b/phpBB/includes/ucp/ucp_auth_link.php @@ -52,6 +52,19 @@ class ucp_auth_link } } + if (isset($provider_data['VARS'])) + { + $template->assign_vars($provider_data['VARS']); + } + + if (isset($provider_data['BLOCK_VAR_NAME'])) + { + foreach ($provider_data['BLOCK_VARS'] as $block_vars) + { + $template->assign_block_vars($provider_data['BLOCK_VAR_NAME'], $block_vars); + } + } + $s_hidden_fields = build_hidden_fields($s_hidden_fields); $template->assign_vars(array( diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index d0b5583d77..1b0674a13b 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -452,7 +452,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base // Get all external accounts tied to the current user $data = array( - 'user_id' => $user->data['user_id'], + 'user_id' => $this->user->data['user_id'], ); $sql = 'SELECT oauth_provider_id, provider FROM ' . $this->auth_provider_oauth_token_account_assoc . ' WHERE ' . $this->db->sql_build_array('SELECT', $data); @@ -462,9 +462,9 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base $oauth_user_ids = array(); - if ($row !== false && !empty($rows)) + if ($rows !== false && !empty($rows)) { - foreach ($row as $row) + foreach ($rows as $row) { $oauth_user_ids[$row['provider']] = $row['oauth_provider_id']; } diff --git a/phpBB/styles/prosilver/template/ucp_auth_link.html b/phpBB/styles/prosilver/template/ucp_auth_link.html index 8ba16c55c8..3c56415db0 100644 --- a/phpBB/styles/prosilver/template/ucp_auth_link.html +++ b/phpBB/styles/prosilver/template/ucp_auth_link.html @@ -2,8 +2,12 @@

{L_UCP_AUTH_LINK_TITLE}

-
{ERROR}
+
+
+
{ERROR}
- + +
+
diff --git a/phpBB/styles/prosilver/template/ucp_auth_link_oauth.html b/phpBB/styles/prosilver/template/ucp_auth_link_oauth.html index ca13ff0ab6..5950535c80 100644 --- a/phpBB/styles/prosilver/template/ucp_auth_link_oauth.html +++ b/phpBB/styles/prosilver/template/ucp_auth_link_oauth.html @@ -1,5 +1,28 @@ -
+ + +

{oauth.SERVICE_NAME}

-{S_HIDDEN_FIELDS} -{S_FORM_TOKEN} -
\ No newline at end of file +
+ +
+
{L_UCP_AUTH_LINK_ID}{L_COLON}
+
{oauth.UNIQUE_ID}
+
+
+
 
+
{S_HIDDEN_FIELDS}
+
+ +
+
{L_UCP_AUTH_LINK_ASK}
+
+
+
 
+
{S_HIDDEN_FIELDS}
+
+ +
+ {S_HIDDEN_FIELDS} + {S_FORM_TOKEN} + + -- cgit v1.2.1 From 836d3ba22ec997f6c823c9b4594fb42c49524732 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 12 Aug 2013 15:29:08 -0400 Subject: [feature/oauth] Handle hidden fields PHPBB3-11673 --- phpBB/includes/ucp/ucp_auth_link.php | 13 +++++++++++++ phpBB/phpbb/auth/provider/oauth/oauth.php | 4 ++++ phpBB/styles/prosilver/template/ucp_auth_link_oauth.html | 5 +++-- 3 files changed, 20 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_auth_link.php b/phpBB/includes/ucp/ucp_auth_link.php index 05896f93b0..5b8169e3de 100644 --- a/phpBB/includes/ucp/ucp_auth_link.php +++ b/phpBB/includes/ucp/ucp_auth_link.php @@ -54,6 +54,13 @@ class ucp_auth_link 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']); } @@ -61,6 +68,12 @@ class ucp_auth_link { 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); } } diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 1b0674a13b..cfffdf2c96 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -481,6 +481,10 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base $redirect_url = build_url(false) . '&login=external&oauth_service=' . $actual_name; $block_vars[$service_name] = array( + 'HIDDEN_FIELDS' => array( + 'oauth_service' => $actual_name, + ), + 'REDIRECT_URL' => redirect($redirect_url, true), 'SERVICE_NAME' => $this->user->lang['AUTH_PROVIDER_OAUTH_SERVICE_' . strtoupper($actual_name)], 'UNIQUE_ID' => (isset($oauth_user_ids[$actual_name])) ? $oauth_user_ids[$actual_name] : null, diff --git a/phpBB/styles/prosilver/template/ucp_auth_link_oauth.html b/phpBB/styles/prosilver/template/ucp_auth_link_oauth.html index 5950535c80..886aca2aa6 100644 --- a/phpBB/styles/prosilver/template/ucp_auth_link_oauth.html +++ b/phpBB/styles/prosilver/template/ucp_auth_link_oauth.html @@ -10,7 +10,7 @@
 
-
{S_HIDDEN_FIELDS}
+
@@ -18,10 +18,11 @@
 
-
{S_HIDDEN_FIELDS}
+
+ {oauth.HIDDEN_FIELDS} {S_HIDDEN_FIELDS} {S_FORM_TOKEN} -- cgit v1.2.1 From 67b1ec5bb85fb40f098a1c568276c8fd9a7b8976 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 14 Aug 2013 15:19:26 -0400 Subject: [feature/oauth] Start implementing link/unlink actions PHPBB3-11673 --- phpBB/includes/ucp/ucp_auth_link.php | 13 +++++++++++++ phpBB/phpbb/auth/provider/oauth/oauth.php | 15 +++++++++++---- phpBB/styles/prosilver/template/ucp_auth_link_oauth.html | 4 ++-- 3 files changed, 26 insertions(+), 6 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_auth_link.php b/phpBB/includes/ucp/ucp_auth_link.php index 5b8169e3de..6c56f8ac3c 100644 --- a/phpBB/includes/ucp/ucp_auth_link.php +++ b/phpBB/includes/ucp/ucp_auth_link.php @@ -48,7 +48,20 @@ class ucp_auth_link if (!sizeof($error)) { + // Any post data could be necessary for auth (un)linking + $link_data = $request->get_super_global(phpbb_request_interface::POST); + // The current user_id is also necessary + $link_data['user_id'] = $user->data['user_id']; + + if ($request->variable('link', false, false, phpbb_request_interface::POST)) + { + $error[] = $auth_provider->link_account($link_data); + } + else + { + $error[] = $auth_provider->unlink_account($link_data); + } } } diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index cfffdf2c96..d2f7eb5527 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -405,10 +405,18 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base return 'LOGIN_LINK_ERROR_OAUTH_NO_ACCESS_TOKEN'; } + // Prepare the query string + if ($this->request->variable('mode', 'login_link')) + { + $query = 'mode=login_link'; + } else { + $query = 'i=ucp_auth_link&mode=auth_link'; + } + $query .= '&login_link_oauth_service=' . strtolower($link_data['oauth_service']); + // Prepare for an authentication request $service_credentials = $this->service_providers[$service_name]->get_service_credentials(); $scopes = $this->service_providers[$service_name]->get_auth_scope(); - $query = 'mode=login_link&login_link_oauth_service=' . strtolower($link_data['oauth_service']); $service = $this->get_service(strtolower($link_data['oauth_service']), $storage, $service_credentials, $scopes, $query); $this->service_providers[$service_name]->set_external_service_provider($service); @@ -462,7 +470,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base $oauth_user_ids = array(); - if ($rows !== false && !empty($rows)) + if ($rows !== false && sizeof($rows)) { foreach ($rows as $row) { @@ -478,14 +486,13 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base if ($credentials['key'] && $credentials['secret']) { $actual_name = str_replace('auth.provider.oauth.service.', '', $service_name); - $redirect_url = build_url(false) . '&login=external&oauth_service=' . $actual_name; $block_vars[$service_name] = array( 'HIDDEN_FIELDS' => array( + 'link' => (!isset($oauth_user_ids[$actual_name])), 'oauth_service' => $actual_name, ), - 'REDIRECT_URL' => redirect($redirect_url, true), 'SERVICE_NAME' => $this->user->lang['AUTH_PROVIDER_OAUTH_SERVICE_' . strtoupper($actual_name)], 'UNIQUE_ID' => (isset($oauth_user_ids[$actual_name])) ? $oauth_user_ids[$actual_name] : null, ); diff --git a/phpBB/styles/prosilver/template/ucp_auth_link_oauth.html b/phpBB/styles/prosilver/template/ucp_auth_link_oauth.html index 886aca2aa6..a50c786b48 100644 --- a/phpBB/styles/prosilver/template/ucp_auth_link_oauth.html +++ b/phpBB/styles/prosilver/template/ucp_auth_link_oauth.html @@ -10,7 +10,7 @@
 
-
+
@@ -18,7 +18,7 @@
 
-
+
-- cgit v1.2.1 From ce387d9bfc2b4a5ac18f79585132862ced0a7687 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 14 Aug 2013 15:21:11 -0400 Subject: [feature/oauth] Fix errors in ucp_auth_link PHPBB3-11673 --- phpBB/includes/ucp/ucp_auth_link.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_auth_link.php b/phpBB/includes/ucp/ucp_auth_link.php index 6c56f8ac3c..213fbfdbb5 100644 --- a/phpBB/includes/ucp/ucp_auth_link.php +++ b/phpBB/includes/ucp/ucp_auth_link.php @@ -21,7 +21,7 @@ class ucp_auth_link public function main($id, $mode) { - global $config, $request, $template, $phpbb_container; + global $config, $request, $template, $phpbb_container, $user; $error = array(); @@ -41,7 +41,7 @@ class ucp_auth_link if (!sizeof($error) && $submit) { - if (!check_form_key('ucp_reg_details')) + if (!check_form_key('ucp_auth_link')) { $error[] = 'FORM_INVALID'; } -- cgit v1.2.1 From afebbf231adeee6828d75d346b64f3036ff46e7c Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 14 Aug 2013 15:35:37 -0400 Subject: [feature/oauth] Update link_account to allow for two methods of linking PHPBB3-11673 --- phpBB/includes/ucp/ucp_auth_link.php | 5 ++++- phpBB/includes/ucp/ucp_login_link.php | 3 +++ phpBB/phpbb/auth/provider/oauth/oauth.php | 13 ++++++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_auth_link.php b/phpBB/includes/ucp/ucp_auth_link.php index 213fbfdbb5..43d69be901 100644 --- a/phpBB/includes/ucp/ucp_auth_link.php +++ b/phpBB/includes/ucp/ucp_auth_link.php @@ -54,7 +54,10 @@ class ucp_auth_link // The current user_id is also necessary $link_data['user_id'] = $user->data['user_id']; - if ($request->variable('link', false, false, phpbb_request_interface::POST)) + // Tell the provider that the method is auth_link not login_link + $link_data['link_method'] = 'auth_link'; + + if ($request->variable('link', null)) { $error[] = $auth_provider->link_account($link_data); } diff --git a/phpBB/includes/ucp/ucp_login_link.php b/phpBB/includes/ucp/ucp_login_link.php index 9f2fa6330a..b09415623b 100644 --- a/phpBB/includes/ucp/ucp_login_link.php +++ b/phpBB/includes/ucp/ucp_login_link.php @@ -73,6 +73,9 @@ class ucp_login_link // Give the user_id to the data $data['user_id'] = $login_result['user_row']['user_id']; + // Set the link_method to login_link + $data['link_method'] = 'login_link'; + // The user is now logged in, attempt to link the user to the external account $result = $auth_provider->link_account($data); diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index d2f7eb5527..36e605d8fc 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -364,7 +364,8 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base return 'LOGIN_LINK_NO_DATA_PROVIDED'; } - if (!array_key_exists('oauth_service', $login_link_data) || !$login_link_data['oauth_service']) + if (!array_key_exists('oauth_service', $login_link_data) || !$login_link_data['oauth_service'] || + !array_key_exists('link_method', $login_link_data) || !$login_link_data['link_method']) { return 'LOGIN_LINK_MISSING_DATA'; } @@ -377,6 +378,16 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base */ public function link_account(array $link_data) { + // Check for a valid link method (auth_link or login_link) + if (!array_key_exists('link_method', $link_data) || + !in_array($link_data['link_method'], array( + 'auth_link', + 'login_link', + ))) + { + return 'LOGIN_LINK_MISSING_DATA'; + } + // We must have an oauth_service listed, check for it two ways if (!array_key_exists('oauth_service', $link_data) || !$link_data['oauth_service']) { -- cgit v1.2.1 From bb68338861e4fc618407f83706d194e1114ce103 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 14 Aug 2013 15:55:38 -0400 Subject: [feature/oauth] Refactor oauth::link_account for two paths PHPBB3-11673 --- phpBB/includes/ucp/ucp_auth_link.php | 14 +++++++- phpBB/phpbb/auth/provider/oauth/oauth.php | 60 +++++++++++++++++++++++++------ 2 files changed, 62 insertions(+), 12 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_auth_link.php b/phpBB/includes/ucp/ucp_auth_link.php index 43d69be901..59eedb7c92 100644 --- a/phpBB/includes/ucp/ucp_auth_link.php +++ b/phpBB/includes/ucp/ucp_auth_link.php @@ -39,6 +39,7 @@ class ucp_auth_link $submit = $request->variable('submit', false, false, phpbb_request_interface::POST); + // This path is only for primary actions if (!sizeof($error) && $submit) { if (!check_form_key('ucp_auth_link')) @@ -57,7 +58,7 @@ class ucp_auth_link // Tell the provider that the method is auth_link not login_link $link_data['link_method'] = 'auth_link'; - if ($request->variable('link', null)) + if ($request->variable('link', null, false, phpbb_request_interface::POST)) { $error[] = $auth_provider->link_account($link_data); } @@ -68,6 +69,17 @@ class ucp_auth_link } } + // In some cases, an 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); + } + if (isset($provider_data['VARS'])) { // Handle hidden fields separately diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 36e605d8fc..ff715d8944 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -408,8 +408,17 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base return 'LOGIN_ERROR_OAUTH_SERVICE_DOES_NOT_EXIST'; } - $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_token_storage_table); + switch ($link_data['link_method']) + { + case 'auth_link': + return $this->link_account_auth_link($link_data, $service_name); + case 'login_link': + return $this->link_account_login_link($link_data, $service_name); + } + } + protected function link_account_login_link(array $link_data, $service_name) + { // Check for an access token, they should have one if (!$storage->has_access_token_by_session()) { @@ -417,13 +426,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base } // Prepare the query string - if ($this->request->variable('mode', 'login_link')) - { - $query = 'mode=login_link'; - } else { - $query = 'i=ucp_auth_link&mode=auth_link'; - } - $query .= '&login_link_oauth_service=' . strtolower($link_data['oauth_service']); + $query = 'mode=login_link&login_link_oauth_service=' . strtolower($link_data['oauth_service']); // Prepare for an authentication request $service_credentials = $this->service_providers[$service_name]->get_service_credentials(); @@ -440,14 +443,49 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base 'provider' => strtolower($link_data['oauth_service']), 'oauth_provider_id' => $unique_id, ); - $sql = 'INSERT INTO ' . $this->auth_provider_oauth_token_account_assoc . ' - ' . $this->db->sql_build_array('INSERT', $data); - $this->db->sql_query($sql); + $this->link_account_perform_link($data); // Update token storage to store the user_id $storage->set_user_id($link_data['user_id']); } + protected function link_account_auth_link(array $link_data, $service_name) + { + $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_token_storage_table); + $query = 'i=ucp_auth_link&mode=auth_link&link=1&login_link_oauth_service=' . strtolower($link_data['oauth_service']); + $service_credentials = $this->service_providers[$service_name]->get_service_credentials(); + $scopes = $this->service_providers[$service_name]->get_auth_scope(); + $service = $this->get_service(strtolower($link_data['oauth_service']), $storage, $service_credentials, $scopes, $query); + + if ($this->request->is_set('code', phpbb_request_interface::GET)) + { + $this->service_providers[$service_name]->set_external_service_provider($service); + $unique_id = $this->service_providers[$service_name]->perform_auth_login(); + + // Insert into table, they will be able to log in after this + $data = array( + 'user_id' => $link_data['user_id'], + 'provider' => strtolower($link_data['oauth_service']), + 'oauth_provider_id' => $unique_id, + ); + + $this->link_account_perform_link($data); + + // Update token storage to store the user_id + $storage->set_user_id($link_data['user_id']); + } else { + $url = $service->getAuthorizationUri(); + header('Location: ' . $url); + } + } + + protected function link_account_perform_link($data) + { + $sql = 'INSERT INTO ' . $this->auth_provider_oauth_token_account_assoc . ' + ' . $this->db->sql_build_array('INSERT', $data); + $this->db->sql_query($sql); + } + /** * {@inheritdoc} */ -- cgit v1.2.1 From cd12786e58995d93bb73218fb869bad00ad9674e Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 14 Aug 2013 16:01:59 -0400 Subject: [feature/oauth] Fix errors found in testing linking PHPBB3-11673 --- phpBB/includes/ucp/ucp_auth_link.php | 2 +- phpBB/phpbb/auth/provider/oauth/oauth.php | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_auth_link.php b/phpBB/includes/ucp/ucp_auth_link.php index 59eedb7c92..b7fd014493 100644 --- a/phpBB/includes/ucp/ucp_auth_link.php +++ b/phpBB/includes/ucp/ucp_auth_link.php @@ -58,7 +58,7 @@ class ucp_auth_link // Tell the provider that the method is auth_link not login_link $link_data['link_method'] = 'auth_link'; - if ($request->variable('link', null, false, phpbb_request_interface::POST)) + if ($request->variable('link', 0, false, phpbb_request_interface::POST)) { $error[] = $auth_provider->link_account($link_data); } diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index ff715d8944..6f6e6fd344 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -391,10 +391,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base // We must have an oauth_service listed, check for it two ways if (!array_key_exists('oauth_service', $link_data) || !$link_data['oauth_service']) { - if (!$link_data['oauth_service'] && $this->request->is_set('oauth_service')) - { - $link_data['oauth_service'] = $this->request->variable('oauth_service', ''); - } + $link_data['oauth_service'] = $this->request->variable('oauth_service', false); if (!$link_data['oauth_service']) { @@ -452,7 +449,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base protected function link_account_auth_link(array $link_data, $service_name) { $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_token_storage_table); - $query = 'i=ucp_auth_link&mode=auth_link&link=1&login_link_oauth_service=' . strtolower($link_data['oauth_service']); + $query = 'i=ucp_auth_link&mode=auth_link&link=1&oauth_service=' . strtolower($link_data['oauth_service']); $service_credentials = $this->service_providers[$service_name]->get_service_credentials(); $scopes = $this->service_providers[$service_name]->get_auth_scope(); $service = $this->get_service(strtolower($link_data['oauth_service']), $storage, $service_credentials, $scopes, $query); @@ -464,7 +461,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base // Insert into table, they will be able to log in after this $data = array( - 'user_id' => $link_data['user_id'], + 'user_id' => $this->user->data['user_id'], 'provider' => strtolower($link_data['oauth_service']), 'oauth_provider_id' => $unique_id, ); -- cgit v1.2.1 From 9c91446ef793102f700fc81b1efc54055b1831ba Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 14 Aug 2013 16:07:38 -0400 Subject: [feature/oauth] Document internal functions PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 6f6e6fd344..be86180574 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -414,6 +414,15 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base } } + /** + * Performs the account linking for login_link + * + * @param array $link_data The same variable given to {@see phpbb_auth_provider_interface::link_account} + * @param string $service_name The name of the service being used in + * linking. + * @return string|null Returns a language constant (string) if an error is + * encountered, or null on success. + */ protected function link_account_login_link(array $link_data, $service_name) { // Check for an access token, they should have one @@ -446,6 +455,15 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base $storage->set_user_id($link_data['user_id']); } + /** + * Performs the account linking for login_link + * + * @param array $link_data The same variable given to {@see phpbb_auth_provider_interface::link_account} + * @param string $service_name The name of the service being used in + * linking. + * @return string|null Returns a language constant (string) if an error is + * encountered, or null on success. + */ protected function link_account_auth_link(array $link_data, $service_name) { $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_token_storage_table); @@ -476,7 +494,12 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base } } - protected function link_account_perform_link($data) + /** + * Performs the query that inserts an account link + * + * @param array $data This array is passed to db->sql_build_array + */ + protected function link_account_perform_link(array $data) { $sql = 'INSERT INTO ' . $this->auth_provider_oauth_token_account_assoc . ' ' . $this->db->sql_build_array('INSERT', $data); -- cgit v1.2.1 From a2237ea8a78b6569213e095bb89a6b3f878d129b Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 14 Aug 2013 16:20:47 -0400 Subject: [feature/oauth] Add unlink_account to auth interface PHPBB3-11673 --- phpBB/phpbb/auth/provider/base.php | 8 ++++++++ phpBB/phpbb/auth/provider/interface.php | 8 ++++++++ 2 files changed, 16 insertions(+) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/base.php b/phpBB/phpbb/auth/provider/base.php index 2f1bf8f601..09e918cee4 100644 --- a/phpBB/phpbb/auth/provider/base.php +++ b/phpBB/phpbb/auth/provider/base.php @@ -101,4 +101,12 @@ abstract class phpbb_auth_provider_base implements phpbb_auth_provider_interface { return; } + + /** + * {@inheritdoc} + */ + public function unlink_account(array $link_data) + { + return; + } } diff --git a/phpBB/phpbb/auth/provider/interface.php b/phpBB/phpbb/auth/provider/interface.php index 21526fd858..4abbd75055 100644 --- a/phpBB/phpbb/auth/provider/interface.php +++ b/phpBB/phpbb/auth/provider/interface.php @@ -166,4 +166,12 @@ interface phpbb_auth_provider_interface * an external account. */ public function link_account(array $link_data); + + /** + * Unlinks an external account from a phpBB account. + * + * @param array $link_data Any data needed to unlink a phpBB account + * from a phpbb account. + */ + public function unlink_account(array $link_data); } -- cgit v1.2.1 From 9cd80345ad05cccb362ec3eba15304c3f43630ed Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 14 Aug 2013 16:32:55 -0400 Subject: [feature/oauth] Implement unlinking in OAuth PHPBB3-11673 --- phpBB/includes/ucp/ucp_auth_link.php | 3 +++ phpBB/phpbb/auth/provider/oauth/oauth.php | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_auth_link.php b/phpBB/includes/ucp/ucp_auth_link.php index b7fd014493..df4b433f42 100644 --- a/phpBB/includes/ucp/ucp_auth_link.php +++ b/phpBB/includes/ucp/ucp_auth_link.php @@ -66,6 +66,9 @@ class ucp_auth_link { $error[] = $auth_provider->unlink_account($link_data); } + + // Template data may have changed, get new data + $provider_data = $auth_provider->get_auth_link_data(); } } diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index be86180574..9af6f04e38 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -575,4 +575,29 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base 'TEMPLATE_FILE' => 'ucp_auth_link_oauth.html', ); } + + /** + * {@inheritdoc} + */ + public function unlink_account(array $link_data) + { + if (!array_key_exists('oauth_service', $link_data) || !$link_data['oauth_service']) + { + return 'LOGIN_LINK_MISSING_DATA'; + } + + // Remove the link + $sql = 'DELETE FROM ' . $this->auth_provider_oauth_token_account_assoc . " + WHERE provider = '" . $this->db->sql_escape($link_data['oauth_service']) . "' + AND user_id = " . (int) $this->user->data['user_id']; + $this->db->sql_query($sql); + + // Clear all tokens belonging to the user on this servce + $sql = 'DELETE FROM ' . $this->auth_provider_oauth_token_storage_table . " + WHERE user_id = " . (int) $this->user->data['user_id'] . " + AND provider = '" . $this->db->sql_escape($link_data['oauth_service']) . "'"; + $this->db->sql_query($sql); + + return; + } } -- cgit v1.2.1 From 7bd4c88ec519fa0bf10558c79994d14243255813 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 14 Aug 2013 16:45:17 -0400 Subject: [feature/oauth] Fix errors in oauth PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 9af6f04e38..0972d59fee 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -425,6 +425,8 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base */ protected function link_account_login_link(array $link_data, $service_name) { + $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_token_storage_table); + // Check for an access token, they should have one if (!$storage->has_access_token_by_session()) { @@ -593,10 +595,9 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base $this->db->sql_query($sql); // Clear all tokens belonging to the user on this servce - $sql = 'DELETE FROM ' . $this->auth_provider_oauth_token_storage_table . " - WHERE user_id = " . (int) $this->user->data['user_id'] . " - AND provider = '" . $this->db->sql_escape($link_data['oauth_service']) . "'"; - $this->db->sql_query($sql); + $service_name = 'auth.provider.oauth.service.' . strtolower($link_data['oauth_service']); + $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_token_storage_table); + $storage->clearToken(); return; } -- cgit v1.2.1 From abebe83edb79b9f3879f8d257eefff01246ba172 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 14 Aug 2013 16:52:37 -0400 Subject: [feature/oauth] No need for this line PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 0972d59fee..bb8b72ac06 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -487,9 +487,6 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base ); $this->link_account_perform_link($data); - - // Update token storage to store the user_id - $storage->set_user_id($link_data['user_id']); } else { $url = $service->getAuthorizationUri(); header('Location: ' . $url); -- cgit v1.2.1 From 823b7e2b84b0c1cfda001c509876f1aef1a17b35 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 14 Aug 2013 16:58:46 -0400 Subject: [feature/oauth] Fix small error in method call PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index bb8b72ac06..6d42b06f6a 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -391,7 +391,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base // We must have an oauth_service listed, check for it two ways if (!array_key_exists('oauth_service', $link_data) || !$link_data['oauth_service']) { - $link_data['oauth_service'] = $this->request->variable('oauth_service', false); + $link_data['oauth_service'] = $this->request->variable('oauth_service', ''); if (!$link_data['oauth_service']) { -- cgit v1.2.1 From 59c8db28d61c9b43ac35f734c0b280bef4a4a8b8 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 14 Aug 2013 17:01:15 -0400 Subject: [feature/oauth] Always store session_id with token PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/token_storage.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/token_storage.php b/phpBB/phpbb/auth/provider/oauth/token_storage.php index b38029c650..313ad7661b 100644 --- a/phpBB/phpbb/auth/provider/oauth/token_storage.php +++ b/phpBB/phpbb/auth/provider/oauth/token_storage.php @@ -110,13 +110,9 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface 'user_id' => $this->user->data['user_id'], 'provider' => $this->service_name, 'oauth_token' => serialize($token), + 'session_id' => $this->user->data['session_id'], ); - if ($this->user->data['user_id'] == ANONYMOUS) - { - $data['session_id'] = $this->user->data['session_id']; - } - $sql = 'INSERT INTO ' . $this->auth_provider_oauth_table . ' ' . $this->db->sql_build_array('INSERT', $data); $this->db->sql_query($sql); -- cgit v1.2.1 From d13a1788f0517f3ecb87d1ecedf24833cf3b403a Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 14 Aug 2013 17:07:38 -0400 Subject: [feature/oauth] Update language constants for ucp_auth_link PHPBB3-11673 --- phpBB/language/en/ucp.php | 6 +++++- phpBB/styles/prosilver/template/ucp_auth_link_oauth.html | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index 4798b1e81c..19892ce194 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -480,8 +480,12 @@ $lang = array_merge($lang, array( 'UCP_AIM' => 'AOL Instant Messenger', 'UCP_ATTACHMENTS' => 'Attachments', 'UCP_AUTH_LINK' => 'External accounts', + 'UCP_AUTH_LINK_ASK' => 'You currently have no account tied to this external service. Click the button below to link your board account to an account with this external service.', + 'UCP_AUTH_LINK_ID' => 'Unique identifier', + 'UCP_AUTH_LINK_LINK' => 'Link', 'UCP_AUTH_LINK_MANAGE' => 'Manage external accounts', - 'UCP_AUTH_LINK_TITLE' => 'Manage Your External Accounts', + 'UCP_AUTH_LINK_TITLE' => 'Manage your external accounts', + 'UCP_AUTH_LINK_UNLINK' => 'Unlink', 'UCP_COPPA_BEFORE' => 'Before %s', 'UCP_COPPA_ON_AFTER' => 'On or after %s', 'UCP_EMAIL_ACTIVATE' => 'Please note that you will need to enter a valid email address before your account is activated. You will receive an email at the address you provide that contains an account activation link.', diff --git a/phpBB/styles/prosilver/template/ucp_auth_link_oauth.html b/phpBB/styles/prosilver/template/ucp_auth_link_oauth.html index a50c786b48..a3e27328cd 100644 --- a/phpBB/styles/prosilver/template/ucp_auth_link_oauth.html +++ b/phpBB/styles/prosilver/template/ucp_auth_link_oauth.html @@ -10,7 +10,7 @@
 
-
+
@@ -18,7 +18,7 @@
 
-
+
-- cgit v1.2.1 From 0ea555bbc78597645cf024a5ba14bfd8149f512a Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 14 Aug 2013 17:15:36 -0400 Subject: [feature/oauth] Update auth provider interface PHPBB3-11673 --- phpBB/phpbb/auth/provider/interface.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/interface.php b/phpBB/phpbb/auth/provider/interface.php index 4abbd75055..480ee4301b 100644 --- a/phpBB/phpbb/auth/provider/interface.php +++ b/phpBB/phpbb/auth/provider/interface.php @@ -167,6 +167,26 @@ interface phpbb_auth_provider_interface */ public function link_account(array $link_data); + /** + * Returns an array of data necessary to build the ucp_auth_link page + * + * @return array|null If this function is not implemented on an auth + * provider then it returns null. If it is implemented + * it will return an array of up to four elements of + * which only 'TEMPLATE_FILE'. If 'BLOCK_VAR_NAME' is + * present then 'BLOCK_VARS' must also be present in + * the array. The fourth element 'VARS' is also + * optional. The array, with all four elements present + * looks like the following: + * array( + * 'TEMPLATE_FILE' => string, + * 'BLOCK_VAR_NAME' => string, + * 'BLOCK_VARS' => array(...), + * 'VARS' => array(...), + * ) + */ + public function get_auth_link_data(); + /** * Unlinks an external account from a phpBB account. * -- cgit v1.2.1 From 43e08e221f9e70940249b93a229dcec0eb10059b Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 14 Aug 2013 22:50:34 -0400 Subject: [feature/oauth] Fix bug found in testing PHPBB3-11673 --- phpBB/includes/ucp/ucp_login_link.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_login_link.php b/phpBB/includes/ucp/ucp_login_link.php index b09415623b..e8e489fe5f 100644 --- a/phpBB/includes/ucp/ucp_login_link.php +++ b/phpBB/includes/ucp/ucp_login_link.php @@ -48,6 +48,9 @@ class ucp_login_link $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) @@ -73,9 +76,6 @@ class ucp_login_link // Give the user_id to the data $data['user_id'] = $login_result['user_row']['user_id']; - // Set the link_method to login_link - $data['link_method'] = 'login_link'; - // The user is now logged in, attempt to link the user to the external account $result = $auth_provider->link_account($data); -- cgit v1.2.1 From 0ea3103a441282190533c973bfb9fe5ab7b7ac76 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 14 Aug 2013 23:00:45 -0400 Subject: [feature/oauth] Don't allow external login methods on admin auth PHPBB3-11673 --- phpBB/styles/prosilver/template/login_body.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/styles/prosilver/template/login_body.html b/phpBB/styles/prosilver/template/login_body.html index e00e5d7a67..a1c2735ca9 100644 --- a/phpBB/styles/prosilver/template/login_body.html +++ b/phpBB/styles/prosilver/template/login_body.html @@ -48,7 +48,7 @@
- + -- cgit v1.2.1 From e2d0a0b7c83f40c0602ed9064e12dded96fdc897 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Wed, 14 Aug 2013 23:17:57 -0400 Subject: [feature/oauth] Fix template not refreshing issue PHPBB3-11673 --- phpBB/includes/ucp/ucp_auth_link.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_auth_link.php b/phpBB/includes/ucp/ucp_auth_link.php index df4b433f42..e2bf369984 100644 --- a/phpBB/includes/ucp/ucp_auth_link.php +++ b/phpBB/includes/ucp/ucp_auth_link.php @@ -81,6 +81,9 @@ class ucp_auth_link $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'])) -- cgit v1.2.1 From 83515cd3d42486b7411ac5e817cb5c2378b75fe8 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 15 Aug 2013 01:14:37 -0400 Subject: [feature/oauth] Fix remaining issues with token storage PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/token_storage.php | 57 ++++++++++++++++++++++- 1 file changed, 55 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/token_storage.php b/phpBB/phpbb/auth/provider/oauth/token_storage.php index 313ad7661b..ff1887fce7 100644 --- a/phpBB/phpbb/auth/provider/oauth/token_storage.php +++ b/phpBB/phpbb/auth/provider/oauth/token_storage.php @@ -16,6 +16,7 @@ if (!defined('IN_PHPBB')) } +use OAuth\OAuth1\Token\StdOAuth1Token; use OAuth\Common\Token\TokenInterface; use OAuth\Common\Storage\TokenStorageInterface; use OAuth\Common\Storage\Exception\StorageException; @@ -109,7 +110,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface $data = array( 'user_id' => $this->user->data['user_id'], 'provider' => $this->service_name, - 'oauth_token' => serialize($token), + 'oauth_token' => $this->json_encode_token($token), 'session_id' => $this->user->data['session_id'], ); @@ -248,7 +249,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface throw new TokenNotFoundException('Token not stored'); } - $token = unserialize($row['oauth_token']); + $token = $this->json_decode_token($row['oauth_token']); // Ensure that the token was serialized/unserialized correctly if (!($token instanceof TokenInterface)) @@ -278,4 +279,56 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface return $row; } + + public function json_encode_token(TokenInterface $token) + { + $members = array( + 'accessToken' => $token->getAccessToken(), + 'endOfLife' => $token->getEndOfLife(), + 'extraParams' => $token->getExtraParams(), + 'refreshToken' => $token->getRefreshToken(), + + 'token_class' => get_class($token), + ); + + // Handle additional data needed for OAuth1 tokens + if ($token instanceof StdOAuth1Token) + { + $members['requestToken'] = $token->getRequestToken(); + $members['requestTokenSecret'] = $token->getRequestTokenSecret(); + $members['accessTokenSecret'] = $token->getAccessTokenSecret(); + } + + return json_encode($members); + } + + public function json_decode_token($json) + { + $token_data = json_decode($json, true); + + if ($token_data === null) + { + throw new TokenNotFoundException('Token not stored correctly'); + } + + $token_class = $token_data['token_class']; + $access_token = $token_data['accessToken']; + $refresh_token = $token_data['refreshToken']; + $endOfLife = $token_data['endOfLife']; + $extra_params = $token_data['extraParams']; + + // Create the token + $token = new $token_class($access_token, $refresh_token, TokenInterface::EOL_NEVER_EXPIRES, $extra_params); + $token->setEndOfLife($endOfLife); + + // Handle OAuth 1.0 specific elements + if ($token instanceof StdOAuth1Token) + { + $token->setRequestToken($token_data['requestToken']); + $token->setRequestTokenSecret($token_data['requestTokenSecret']); + $token->setAccessTokenSecret($token_data['accessTokenSecret']); + } + + return $token; + } } -- cgit v1.2.1 From 8f75edb8a13dd4e32790652cb1a292db395d786d Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 22 Aug 2013 19:10:43 -0400 Subject: [feature/oauth] Add newline at end of file PHPBB3-11673 --- phpBB/styles/prosilver/template/login_body_oauth.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/styles/prosilver/template/login_body_oauth.html b/phpBB/styles/prosilver/template/login_body_oauth.html index eb6c627c6f..dbbe011c58 100644 --- a/phpBB/styles/prosilver/template/login_body_oauth.html +++ b/phpBB/styles/prosilver/template/login_body_oauth.html @@ -5,4 +5,4 @@
{oauth.SERVICE_NAME}
- \ No newline at end of file + -- cgit v1.2.1 From dbf97fdd52043611a86cb48920bb152122b3f6c2 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 22 Aug 2013 19:37:46 -0400 Subject: [feature/oauth] Subsilver 2 login_body updates PHPBB3-11673 --- phpBB/styles/subsilver2/template/login_body.html | 3 +++ phpBB/styles/subsilver2/template/login_body_oauth.html | 7 +++++++ 2 files changed, 10 insertions(+) create mode 100644 phpBB/styles/subsilver2/template/login_body_oauth.html (limited to 'phpBB') diff --git a/phpBB/styles/subsilver2/template/login_body.html b/phpBB/styles/subsilver2/template/login_body.html index 2b895dda89..ed63e748cf 100644 --- a/phpBB/styles/subsilver2/template/login_body.html +++ b/phpBB/styles/subsilver2/template/login_body.html @@ -61,6 +61,9 @@ {L_HIDE_ME} + + + diff --git a/phpBB/styles/subsilver2/template/login_body_oauth.html b/phpBB/styles/subsilver2/template/login_body_oauth.html new file mode 100644 index 0000000000..6f374fa4f2 --- /dev/null +++ b/phpBB/styles/subsilver2/template/login_body_oauth.html @@ -0,0 +1,7 @@ + + + + {oauth.SERVICE_NAME} + + + -- cgit v1.2.1 From 5f81d66c2f666c1825950228e87e7ac6c6b4ca2c Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 23 Aug 2013 03:55:26 +0200 Subject: [ticket/11799] Send anti abuse headers in "new password" emails. PHPBB3-11799 --- phpBB/includes/ucp/ucp_remind.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_remind.php b/phpBB/includes/ucp/ucp_remind.php index cb89ad99be..bcb21cbedc 100644 --- a/phpBB/includes/ucp/ucp_remind.php +++ b/phpBB/includes/ucp/ucp_remind.php @@ -98,6 +98,8 @@ class ucp_remind $messenger->to($user_row['user_email'], $user_row['username']); $messenger->im($user_row['user_jabber'], $user_row['username']); + $messenger->anti_abuse_headers($config, $user); + $messenger->assign_vars(array( 'USERNAME' => htmlspecialchars_decode($user_row['username']), 'PASSWORD' => htmlspecialchars_decode($user_password), -- cgit v1.2.1 From 2845b153d8e86b80c6b9a8c0869474affb277516 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 23 Aug 2013 22:52:33 +0200 Subject: [ticket/11769] Correctly supply the post author's username in posting.php Only supply the username, when it is a guest posting or we edit and it was supplied, otherwise post_data might hold data of the post we quote, in which case username is the original poster, not the current one. PHPBB3-11769 --- phpBB/includes/functions_posting.php | 5 ++++- phpBB/posting.php | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 2e5130c5b8..aff7129fce 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -2604,7 +2604,10 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u // Send Notifications if (($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $post_approval) { - $username = ($username) ? $username : $user->data['username']; + // If a username was supplied or the poster is a guest, we use the supplied username. + // This way we will use "...post by guest-username..." in notifications, + // when guest-username was supplied and ommit the username-part otherwise. + $username = ($username || !$user->data['is_registered']) ? $username : $user->data['username']; user_notification($mode, $subject, $data['topic_title'], $data['forum_name'], $data['forum_id'], $data['topic_id'], $data['post_id'], $username); } diff --git a/phpBB/posting.php b/phpBB/posting.php index 42c4f7bc55..d690445fdb 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1131,8 +1131,13 @@ if ($submit || $preview || $refresh) $data['topic_replies'] = $post_data['topic_replies']; } + // Only supply the username, when it is a guest posting or we edit and it was supplied, + // otherwise post_data might hold data of the post we quote, in which case + // username is the original poster, not the current one. See: PHPBB3-11769 + $post_author_name = ((!$user->data['is_registered'] || $mode == 'edit') && $post_data['username']) ? $post_data['username'] : ''; + // The last parameter tells submit_post if search indexer has to be run - $redirect_url = submit_post($mode, $post_data['post_subject'], $post_data['username'], $post_data['topic_type'], $poll, $data, $update_message, ($update_message || $update_subject) ? true : false); + $redirect_url = submit_post($mode, $post_data['post_subject'], $post_author_name, $post_data['topic_type'], $poll, $data, $update_message, ($update_message || $update_subject) ? true : false); if ($config['enable_post_confirm'] && !$user->data['is_registered'] && (isset($captcha) && $captcha->is_solved() === true) && ($mode == 'post' || $mode == 'reply' || $mode == 'quote')) { -- cgit v1.2.1 From d717203af1263e552886251fbee9b718be45f623 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 23 Aug 2013 23:49:11 +0200 Subject: [ticket/11769] Fix language issues in the doc blocks PHPBB3-11769 --- phpBB/includes/functions_posting.php | 6 +++--- phpBB/posting.php | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index aff7129fce..32206df868 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -2604,9 +2604,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u // Send Notifications if (($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $post_approval) { - // If a username was supplied or the poster is a guest, we use the supplied username. - // This way we will use "...post by guest-username..." in notifications, - // when guest-username was supplied and ommit the username-part otherwise. + // If a username was supplied or the poster is a guest, we will use the supplied username. + // Doing it this way we can use "...post by guest-username..." in notifications when + // "guest-username" is supplied or ommit the username if it is not. $username = ($username || !$user->data['is_registered']) ? $username : $user->data['username']; user_notification($mode, $subject, $data['topic_title'], $data['forum_name'], $data['forum_id'], $data['topic_id'], $data['post_id'], $username); } diff --git a/phpBB/posting.php b/phpBB/posting.php index d690445fdb..7ab4773df2 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1131,9 +1131,10 @@ if ($submit || $preview || $refresh) $data['topic_replies'] = $post_data['topic_replies']; } - // Only supply the username, when it is a guest posting or we edit and it was supplied, - // otherwise post_data might hold data of the post we quote, in which case - // username is the original poster, not the current one. See: PHPBB3-11769 + // Only return the username when it is either a guest posting or we are editing a post and + // the username was supplied; otherwise post_data might hold the data of the post that is + // being quoted (which could result in the username being returned being that of the quoted + // post's poster, not the poster of the current post). See: PHPBB3-11769 for more information. $post_author_name = ((!$user->data['is_registered'] || $mode == 'edit') && $post_data['username']) ? $post_data['username'] : ''; // The last parameter tells submit_post if search indexer has to be run -- cgit v1.2.1 From 2ce83fce1eb3031b71a54a555b8766f35d8b6ac7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 23 Aug 2013 23:53:33 +0200 Subject: [ticket/11769] Allow '0' as username in notification mails PHPBB3-11769 --- phpBB/language/en/email/forum_notify.txt | 2 +- phpBB/language/en/email/newtopic_notify.txt | 2 +- phpBB/language/en/email/topic_notify.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/language/en/email/forum_notify.txt b/phpBB/language/en/email/forum_notify.txt index 490780a0a6..6a2eb90190 100644 --- a/phpBB/language/en/email/forum_notify.txt +++ b/phpBB/language/en/email/forum_notify.txt @@ -2,7 +2,7 @@ Subject: Forum post notification - "{FORUM_NAME}" Hello {USERNAME}, -You are receiving this notification because you are watching the forum, "{FORUM_NAME}" at "{SITENAME}". This forum has received a new reply to the topic "{TOPIC_TITLE}" by {AUTHOR_NAME} since your last visit. You can use the following link to view the last unread reply, no more notifications will be sent until you visit the topic. +You are receiving this notification because you are watching the forum, "{FORUM_NAME}" at "{SITENAME}". This forum has received a new reply to the topic "{TOPIC_TITLE}" by {AUTHOR_NAME} since your last visit. You can use the following link to view the last unread reply, no more notifications will be sent until you visit the topic. {U_NEWEST_POST} diff --git a/phpBB/language/en/email/newtopic_notify.txt b/phpBB/language/en/email/newtopic_notify.txt index eda1370938..2da7ee8766 100644 --- a/phpBB/language/en/email/newtopic_notify.txt +++ b/phpBB/language/en/email/newtopic_notify.txt @@ -2,7 +2,7 @@ Subject: New topic notification - "{FORUM_NAME}" Hello {USERNAME}, -You are receiving this notification because you are watching the forum, "{FORUM_NAME}" at "{SITENAME}". This forum has received a new topic by {AUTHOR_NAME} since your last visit, "{TOPIC_TITLE}". You can use the following link to view the forum, no more notifications will be sent until you visit the forum. +You are receiving this notification because you are watching the forum, "{FORUM_NAME}" at "{SITENAME}". This forum has received a new topic by {AUTHOR_NAME} since your last visit, "{TOPIC_TITLE}". You can use the following link to view the forum, no more notifications will be sent until you visit the forum. {U_FORUM} diff --git a/phpBB/language/en/email/topic_notify.txt b/phpBB/language/en/email/topic_notify.txt index fcfbcc2abd..f48eb5d40a 100644 --- a/phpBB/language/en/email/topic_notify.txt +++ b/phpBB/language/en/email/topic_notify.txt @@ -2,7 +2,7 @@ Subject: Topic reply notification - "{TOPIC_TITLE}" Hello {USERNAME}, -You are receiving this notification because you are watching the topic, "{TOPIC_TITLE}" at "{SITENAME}". This topic has received a reply by {AUTHOR_NAME} since your last visit. You can use the following link to view the replies made, no more notifications will be sent until you visit the topic. +You are receiving this notification because you are watching the topic, "{TOPIC_TITLE}" at "{SITENAME}". This topic has received a reply by {AUTHOR_NAME} since your last visit. You can use the following link to view the replies made, no more notifications will be sent until you visit the topic. If you want to view the newest post made since your last visit, click the following link: {U_NEWEST_POST} -- cgit v1.2.1 From cbd5bbbeb8358a3279ce82cac9becbe55d7803b1 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 24 Aug 2013 16:36:14 -0400 Subject: [feature/oauth] Subsilver2 ucp_auth_link templates PHPBB3-11673 --- .../styles/subsilver2/template/ucp_auth_link.html | 17 +++++++++++ .../subsilver2/template/ucp_auth_link_oauth.html | 34 ++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 phpBB/styles/subsilver2/template/ucp_auth_link.html create mode 100644 phpBB/styles/subsilver2/template/ucp_auth_link_oauth.html (limited to 'phpBB') diff --git a/phpBB/styles/subsilver2/template/ucp_auth_link.html b/phpBB/styles/subsilver2/template/ucp_auth_link.html new file mode 100644 index 0000000000..c6e4ddd250 --- /dev/null +++ b/phpBB/styles/subsilver2/template/ucp_auth_link.html @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + +
{L_UCP_AUTH_LINK_TITLE}
{ERROR}
+ + diff --git a/phpBB/styles/subsilver2/template/ucp_auth_link_oauth.html b/phpBB/styles/subsilver2/template/ucp_auth_link_oauth.html new file mode 100644 index 0000000000..56a4c89125 --- /dev/null +++ b/phpBB/styles/subsilver2/template/ucp_auth_link_oauth.html @@ -0,0 +1,34 @@ + + + {oauth.SERVICE_NAME} + + + + +
+ + + + + + + + + + + + + + + + + + +
{L_UCP_AUTH_LINK_ID}{L_COLON}{oauth.UNIQUE_ID}
 
{L_UCP_AUTH_LINK_ASK}
+ {oauth.HIDDEN_FIELDS} + {S_HIDDEN_FIELDS} + {S_FORM_TOKEN} +
+ + + -- cgit v1.2.1 From de17d5bdcc1cab495b0b3f2d345fa3ac21f3676c Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 24 Aug 2013 17:07:44 -0400 Subject: [feature/oauth] Subsilver2 ucp_login_link PHPBB3-11673 --- .../styles/subsilver2/template/ucp_login_link.html | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 phpBB/styles/subsilver2/template/ucp_login_link.html (limited to 'phpBB') diff --git a/phpBB/styles/subsilver2/template/ucp_login_link.html b/phpBB/styles/subsilver2/template/ucp_login_link.html new file mode 100644 index 0000000000..36ed8a4cc5 --- /dev/null +++ b/phpBB/styles/subsilver2/template/ucp_login_link.html @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
{SITENAME} - {L_LOGIN_LINK}
{L_LOGIN_LINK_EXPLAIN}
{LOGIN_LINK_ERROR}
+
+ + + + + + + + +
{L_REGISTER}
{S_HIDDEN_FIELDS}
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + {S_LOGIN_REDIRECT} + + + + +
{L_LOGIN}
{LOGIN_ERROR}
 {S_HIDDEN_FIELDS}
+
+
+ + -- cgit v1.2.1 From 27ba57747ab46c0507acc3a87e5b73babda436b1 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 24 Aug 2013 17:14:30 -0400 Subject: [feature/oauth] Clean up TODOs PHPBB3-11673 --- phpBB/includes/ucp/ucp_login_link.php | 1 - phpBB/language/en/common.php | 2 ++ phpBB/phpbb/auth/provider/oauth/oauth.php | 4 +--- phpBB/phpbb/auth/provider/oauth/service/bitly.php | 5 ++--- phpBB/phpbb/auth/provider/oauth/service/facebook.php | 2 +- phpBB/phpbb/auth/provider/oauth/service/google.php | 6 ++---- 6 files changed, 8 insertions(+), 12 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_login_link.php b/phpBB/includes/ucp/ucp_login_link.php index e8e489fe5f..d782e26c2c 100644 --- a/phpBB/includes/ucp/ucp_login_link.php +++ b/phpBB/includes/ucp/ucp_login_link.php @@ -200,7 +200,6 @@ class ucp_login_link protected function perform_redirect() { - // TODO: Make redirect to same page as login would have redirect('index.php'); } } diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 0b658f22b6..7d6c7aa1be 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -88,6 +88,8 @@ $lang = array_merge($lang, array( 'ATTACHED_IMAGE_NOT_IMAGE' => 'The image file you tried to attach is invalid.', 'AUTHOR' => 'Author', 'AUTH_NO_PROFILE_CREATED' => 'The creation of a user profile was unsuccessful.', + 'AUTH_PROVIDER_OAUTH_ERROR_INVALID_ENTRY' => 'Invalid database entry.', + 'AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE' => 'Invalid service type provided to OAuth service handler.', 'AUTH_PROVIDER_OAUTH_SERVICE_BITLY' => 'Bitly', 'AUTH_PROVIDER_OAUTH_SERVICE_FACEBOOK' => 'Facebook', 'AUTH_PROVIDER_OAUTH_SERVICE_GOOGLE' => 'Google', diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 6d42b06f6a..e1172f2e70 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -201,8 +201,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base if (!$row) { - // TODO: Update exception type and change it to language constant - throw new Exception('Invalid entry in ' . $this->auth_provider_oauth_token_account_assoc); + throw new Exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_ENTRY'); } // Update token storage to store the user_id @@ -216,7 +215,6 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base ); } else { $url = $service->getAuthorizationUri(); - // TODO: modify $url for the appropriate return points header('Location: ' . $url); } } diff --git a/phpBB/phpbb/auth/provider/oauth/service/bitly.php b/phpBB/phpbb/auth/provider/oauth/service/bitly.php index 9b8e7ebb03..0918f577ec 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/bitly.php +++ b/phpBB/phpbb/auth/provider/oauth/service/bitly.php @@ -67,7 +67,7 @@ class phpbb_auth_provider_oauth_service_bitly extends phpbb_auth_provider_oauth_ if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Bitly)) { // TODO: make exception class and use language constant - throw new Exception('Invalid service provider type'); + throw new Exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); } // This was a callback request from bitly, get the token @@ -87,8 +87,7 @@ class phpbb_auth_provider_oauth_service_bitly extends phpbb_auth_provider_oauth_ { if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Bitly)) { - // TODO: make exception class and use language constant - throw new Exception('Invalid service provider type'); + throw new Exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); } // Send a request with it diff --git a/phpBB/phpbb/auth/provider/oauth/service/facebook.php b/phpBB/phpbb/auth/provider/oauth/service/facebook.php index dc742cca0d..836e4ee052 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/facebook.php +++ b/phpBB/phpbb/auth/provider/oauth/service/facebook.php @@ -67,7 +67,7 @@ class phpbb_auth_provider_oauth_service_facebook extends phpbb_auth_provider_oau if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Facebook)) { // TODO: make exception class and use language constant - throw new Exception('Invalid service provider type'); + throw new Exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); } // This was a callback request, get the token diff --git a/phpBB/phpbb/auth/provider/oauth/service/google.php b/phpBB/phpbb/auth/provider/oauth/service/google.php index e2b0f7d36a..9c782bcaa0 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/google.php +++ b/phpBB/phpbb/auth/provider/oauth/service/google.php @@ -77,8 +77,7 @@ class phpbb_auth_provider_oauth_service_google extends phpbb_auth_provider_oauth { if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Google)) { - // TODO: make exception class and use language constant - throw new Exception('Invalid service provider type'); + throw new Exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); } // This was a callback request, get the token @@ -98,8 +97,7 @@ class phpbb_auth_provider_oauth_service_google extends phpbb_auth_provider_oauth { if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Google)) { - // TODO: make exception class and use language constant - throw new Exception('Invalid service provider type'); + throw new Exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); } // Send a request with it -- cgit v1.2.1 From d398ae41c031f70946e82f71599f1821766f3eea Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 24 Aug 2013 17:20:01 -0400 Subject: [feature/oauth] Finish cleaning up TODOs PHPBB3-11673 --- phpBB/language/en/common.php | 2 ++ phpBB/phpbb/auth/provider/oauth/token_storage.php | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB') diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 7d6c7aa1be..b558b0fad8 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -93,6 +93,8 @@ $lang = array_merge($lang, array( 'AUTH_PROVIDER_OAUTH_SERVICE_BITLY' => 'Bitly', 'AUTH_PROVIDER_OAUTH_SERVICE_FACEBOOK' => 'Facebook', 'AUTH_PROVIDER_OAUTH_SERVICE_GOOGLE' => 'Google', + 'AUTH_PROVIDER_OAUTH_TOKEN_ERROR_NOT_STORED' => 'OAuth token not stored.', + 'AUTH_PROVIDER_OAUTH_TOKEN_ERROR_INCORRECTLY_STORED' => 'OAuth token incorrectly stored.', 'AVATAR_DISALLOWED_CONTENT' => 'The upload was rejected because the uploaded file was identified as a possible attack vector.', 'AVATAR_DISALLOWED_EXTENSION' => 'This file cannot be displayed because the extension %s is not allowed.', 'AVATAR_EMPTY_REMOTE_DATA' => 'The specified avatar could not be uploaded because the remote data appears to be invalid or corrupted.', diff --git a/phpBB/phpbb/auth/provider/oauth/token_storage.php b/phpBB/phpbb/auth/provider/oauth/token_storage.php index ff1887fce7..b31ffcd1ab 100644 --- a/phpBB/phpbb/auth/provider/oauth/token_storage.php +++ b/phpBB/phpbb/auth/provider/oauth/token_storage.php @@ -245,8 +245,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface if (!$row) { - // TODO: translate - throw new TokenNotFoundException('Token not stored'); + throw new TokenNotFoundException('AUTH_PROVIDER_OAUTH_TOKEN_ERROR_NOT_STORED'); } $token = $this->json_decode_token($row['oauth_token']); @@ -255,8 +254,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface if (!($token instanceof TokenInterface)) { $this->clearToken(); - // TODO: translate - throw new TokenNotFoundException('Token not stored correctly'); + throw new TokenNotFoundException('AUTH_PROVIDER_OAUTH_TOKEN_ERROR_INCORRECTLY_STORED'); } $this->cachedToken = $token; -- cgit v1.2.1 From 3df958502960b68e37f3cd9d3d51a4ff1d319fde Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 24 Aug 2013 17:21:02 -0400 Subject: [feature/oauth] Fix indentation on new language constants PHPBB3-11673 --- phpBB/language/en/common.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'phpBB') diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index b558b0fad8..8c36edec58 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -88,13 +88,13 @@ $lang = array_merge($lang, array( 'ATTACHED_IMAGE_NOT_IMAGE' => 'The image file you tried to attach is invalid.', 'AUTHOR' => 'Author', 'AUTH_NO_PROFILE_CREATED' => 'The creation of a user profile was unsuccessful.', - 'AUTH_PROVIDER_OAUTH_ERROR_INVALID_ENTRY' => 'Invalid database entry.', - 'AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE' => 'Invalid service type provided to OAuth service handler.', - 'AUTH_PROVIDER_OAUTH_SERVICE_BITLY' => 'Bitly', - 'AUTH_PROVIDER_OAUTH_SERVICE_FACEBOOK' => 'Facebook', - 'AUTH_PROVIDER_OAUTH_SERVICE_GOOGLE' => 'Google', - 'AUTH_PROVIDER_OAUTH_TOKEN_ERROR_NOT_STORED' => 'OAuth token not stored.', - 'AUTH_PROVIDER_OAUTH_TOKEN_ERROR_INCORRECTLY_STORED' => 'OAuth token incorrectly stored.', + 'AUTH_PROVIDER_OAUTH_ERROR_INVALID_ENTRY' => 'Invalid database entry.', + 'AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE' => 'Invalid service type provided to OAuth service handler.', + 'AUTH_PROVIDER_OAUTH_SERVICE_BITLY' => 'Bitly', + 'AUTH_PROVIDER_OAUTH_SERVICE_FACEBOOK' => 'Facebook', + 'AUTH_PROVIDER_OAUTH_SERVICE_GOOGLE' => 'Google', + 'AUTH_PROVIDER_OAUTH_TOKEN_ERROR_NOT_STORED' => 'OAuth token not stored.', + 'AUTH_PROVIDER_OAUTH_TOKEN_ERROR_INCORRECTLY_STORED' => 'OAuth token incorrectly stored.', 'AVATAR_DISALLOWED_CONTENT' => 'The upload was rejected because the uploaded file was identified as a possible attack vector.', 'AVATAR_DISALLOWED_EXTENSION' => 'This file cannot be displayed because the extension %s is not allowed.', 'AVATAR_EMPTY_REMOTE_DATA' => 'The specified avatar could not be uploaded because the remote data appears to be invalid or corrupted.', -- cgit v1.2.1 From 76d1e7e111d4a12f50e3c4776b00a6681a83b295 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 24 Aug 2013 21:14:37 -0400 Subject: [feature/oauth] Fix issues on ucp_login_link from review PHPBB3-11673 --- phpBB/includes/ucp/ucp_login_link.php | 41 ++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_login_link.php b/phpBB/includes/ucp/ucp_login_link.php index d782e26c2c..2ed6a985d5 100644 --- a/phpBB/includes/ucp/ucp_login_link.php +++ b/phpBB/includes/ucp/ucp_login_link.php @@ -23,8 +23,17 @@ if (!defined('IN_PHPBB')) */ class ucp_login_link { - var $u_action; - + /** + * @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; @@ -112,6 +121,14 @@ class 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(); @@ -124,6 +141,12 @@ class ucp_login_link 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; @@ -143,6 +166,13 @@ class ucp_login_link 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; @@ -198,8 +228,13 @@ class ucp_login_link return $login_error; } + /** + * Performs a post login redirect + */ protected function perform_redirect() { - redirect('index.php'); + global $phpEx; + $url = append_sid('index.' . $phpEx); + redirect($url); } } -- cgit v1.2.1 From 310caec5d92d58453d1eee40e9b5a7f0157bd5ea Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 24 Aug 2013 21:34:23 -0400 Subject: [feature/oauth] Fix redirects PHPBB3-11673 --- phpBB/config/auth_providers.yml | 2 ++ phpBB/phpbb/auth/auth.php | 7 ++----- phpBB/phpbb/auth/provider/oauth/oauth.php | 24 +++++++++++++++++++++--- 3 files changed, 25 insertions(+), 8 deletions(-) (limited to 'phpBB') diff --git a/phpBB/config/auth_providers.yml b/phpBB/config/auth_providers.yml index bad6be9880..dfa229fa42 100644 --- a/phpBB/config/auth_providers.yml +++ b/phpBB/config/auth_providers.yml @@ -46,6 +46,8 @@ services: - %tables.auth_provider_oauth_account_assoc% - @auth.provider.oauth.service_collection - %tables.users% + - %core.root_path% + - %core.php_ext% tags: - { name: auth.provider } auth.provider.oauth.service_collection: diff --git a/phpBB/phpbb/auth/auth.php b/phpBB/phpbb/auth/auth.php index 400f5fef6d..5093483d4a 100644 --- a/phpBB/phpbb/auth/auth.php +++ b/phpBB/phpbb/auth/auth.php @@ -975,12 +975,9 @@ class phpbb_auth { // If this status exists a fourth field is in the $login array called 'redirect_data' // This data is passed along as GET data to the next page allow the account to be linked - $url = 'ucp.php?mode=login_link'; - foreach ($login['redirect_data'] as $key => $value) - { - $url .= '&' . $key . '=' . $value; - } + $params = array('mode' => 'login_link'); + $url = append_sid('ucp.' . $phpEx, array_merge($params, $login['redirect_data'])); redirect($url); } diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index e1172f2e70..b427ca4e72 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -88,6 +88,20 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base */ protected $current_uri; + /** + * phpBB root path + * + * @var string + */ + protected $phpbb_root_path; + + /** + * PHP extenstion + * + * @var string + */ + protected $php_ext; + /** * OAuth Authentication Constructor * @@ -98,9 +112,11 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base * @param string $auth_provider_oauth_token_storage_table * @param string $auth_provider_oauth_token_account_assoc * @param phpbb_di_service_collection $service_providers Contains phpbb_auth_provider_oauth_service_interface - * @param string $users)table + * @param string $users_table + * @param string $phpbb_root_path + * @param string $php_ext */ - public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_request $request, phpbb_user $user, $auth_provider_oauth_token_storage_table, $auth_provider_oauth_token_account_assoc, phpbb_di_service_collection $service_providers, $users_table) + public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_request $request, phpbb_user $user, $auth_provider_oauth_token_storage_table, $auth_provider_oauth_token_account_assoc, phpbb_di_service_collection $service_providers, $users_table, $phpbb_root_path, $php_ext) { $this->db = $db; $this->config = $config; @@ -110,6 +126,8 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base $this->auth_provider_oauth_token_account_assoc = $auth_provider_oauth_token_account_assoc; $this->service_providers = $service_providers; $this->users_table = $users_table; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; } /** @@ -138,7 +156,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base // Temporary workaround for only having one authentication provider available if (!$this->request->is_set('oauth_service')) { - $provider = new phpbb_auth_provider_db($this->db, $this->config, $this->request, $this->user, $phpbb_root_path, $phpEx); + $provider = new phpbb_auth_provider_db($this->db, $this->config, $this->request, $this->user, $this->phpbb_root_path, $this->php_ext); return $provider->login($username, $password); } -- cgit v1.2.1 From a8ffbce99f9ea99bd1fdca0e009001026e2d6950 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 24 Aug 2013 22:00:16 -0400 Subject: [feature/oauth] Changes due to code review PHPBB3-11673 --- phpBB/includes/ucp/ucp_auth_link.php | 32 +++++++++----------- phpBB/includes/ucp/ucp_login_link.php | 4 ++- phpBB/language/en/common.php | 1 + phpBB/language/en/ucp.php | 10 +++---- phpBB/phpbb/auth/provider/interface.php | 8 ++--- phpBB/phpbb/auth/provider/oauth/oauth.php | 17 ++++++----- phpBB/phpbb/auth/provider/oauth/service/bitly.php | 6 ++-- .../phpbb/auth/provider/oauth/service/facebook.php | 10 +++---- phpBB/phpbb/auth/provider/oauth/service/google.php | 6 ++-- phpBB/phpbb/auth/provider/oauth/token_storage.php | 35 ++++++++++------------ 10 files changed, 62 insertions(+), 67 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_auth_link.php b/phpBB/includes/ucp/ucp_auth_link.php index e2bf369984..4fa984c9e7 100644 --- a/phpBB/includes/ucp/ucp_auth_link.php +++ b/phpBB/includes/ucp/ucp_auth_link.php @@ -17,8 +17,17 @@ if (!defined('IN_PHPBB')) 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; @@ -72,7 +81,7 @@ class ucp_auth_link } } - // In some cases, an request to an external server may be required in + // 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)) { @@ -114,8 +123,11 @@ class ucp_auth_link $s_hidden_fields = build_hidden_fields($s_hidden_fields); + // Replace "error" strings with their real, localised form + $error = array_map(array($user, 'lang'), $error); + $template->assign_vars(array( - 'ERROR' => $this->build_error_text($error), + 'ERROR' => $error, 'PROVIDER_TEMPLATE_FILE' => $provider_data['TEMPLATE_FILE'], @@ -126,20 +138,4 @@ class ucp_auth_link $this->tpl_name = 'ucp_auth_link'; $this->page_title = 'UCP_AUTH_LINK'; } - - private function build_error_text(array $errors) - { - global $user; - - // Replace all errors that are language constants - foreach ($errors as $key => $error) - { - if (isset($user->lang[$error])) - { - $errors[$key] = $user->lang($error); - } - } - - return implode('
', $errors); - } } diff --git a/phpBB/includes/ucp/ucp_login_link.php b/phpBB/includes/ucp/ucp_login_link.php index 2ed6a985d5..4173c54c42 100644 --- a/phpBB/includes/ucp/ucp_login_link.php +++ b/phpBB/includes/ucp/ucp_login_link.php @@ -91,7 +91,9 @@ class ucp_login_link if ($result) { $login_link_error = $user->lang[$result]; - } else { + } + else + { // Finish login $result = $user->session_create($login_result['user_row']['user_id'], false, false, true); diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 8c36edec58..5c7df2c5fd 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -90,6 +90,7 @@ $lang = array_merge($lang, array( 'AUTH_NO_PROFILE_CREATED' => 'The creation of a user profile was unsuccessful.', 'AUTH_PROVIDER_OAUTH_ERROR_INVALID_ENTRY' => 'Invalid database entry.', 'AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE' => 'Invalid service type provided to OAuth service handler.', + 'AUTH_PROVIDER_OAUTH_ERROR_SERVICE_NOT_CREATED' => 'OAuth service not created', 'AUTH_PROVIDER_OAUTH_SERVICE_BITLY' => 'Bitly', 'AUTH_PROVIDER_OAUTH_SERVICE_FACEBOOK' => 'Facebook', 'AUTH_PROVIDER_OAUTH_SERVICE_GOOGLE' => 'Google', diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index 19892ce194..03a14336b5 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -270,7 +270,7 @@ $lang = array_merge($lang, array( 'LINK_REMOTE_SIZE' => 'Avatar dimensions', 'LINK_REMOTE_SIZE_EXPLAIN' => 'Specify the width and height of the avatar, leave blank to attempt automatic verification.', 'LOGIN_EXPLAIN_UCP' => 'Please login in order to access the User Control Panel.', - 'LOGIN_LINK' => 'Link or Register Your External Account with This Board', + 'LOGIN_LINK' => 'Link or register your account on an external service with your board account', 'LOGIN_LINK_EXPLAIN' => 'You have attempted to login with an external service that is not yet connected to an account on this board. You must now either link this account to an existing account or create a new account.', 'LOGIN_LINK_MISSING_DATA' => 'Data that is necessary to link your account with an external service is not available. Please restart the login process.', 'LOGIN_LINK_NO_DATA_PROVIDED' => 'No data has been provided to this page to link an external account to a forum account. Please contact the board administrator if you continue to experience problems.', @@ -480,18 +480,18 @@ $lang = array_merge($lang, array( 'UCP_AIM' => 'AOL Instant Messenger', 'UCP_ATTACHMENTS' => 'Attachments', 'UCP_AUTH_LINK' => 'External accounts', - 'UCP_AUTH_LINK_ASK' => 'You currently have no account tied to this external service. Click the button below to link your board account to an account with this external service.', + 'UCP_AUTH_LINK_ASK' => 'You currently have no account associated with this external service. Click the button below to link your board account to an account with this external service.', 'UCP_AUTH_LINK_ID' => 'Unique identifier', 'UCP_AUTH_LINK_LINK' => 'Link', - 'UCP_AUTH_LINK_MANAGE' => 'Manage external accounts', - 'UCP_AUTH_LINK_TITLE' => 'Manage your external accounts', + 'UCP_AUTH_LINK_MANAGE' => 'Manage external account associations', + 'UCP_AUTH_LINK_TITLE' => 'Manage your external account associations', 'UCP_AUTH_LINK_UNLINK' => 'Unlink', 'UCP_COPPA_BEFORE' => 'Before %s', 'UCP_COPPA_ON_AFTER' => 'On or after %s', 'UCP_EMAIL_ACTIVATE' => 'Please note that you will need to enter a valid email address before your account is activated. You will receive an email at the address you provide that contains an account activation link.', 'UCP_ICQ' => 'ICQ number', 'UCP_JABBER' => 'Jabber address', - 'UCP_LOGIN_LINK' => 'Set up an external account', + 'UCP_LOGIN_LINK' => 'Set up an external account association', 'UCP_MAIN' => 'Overview', 'UCP_MAIN_ATTACHMENTS' => 'Manage attachments', diff --git a/phpBB/phpbb/auth/provider/interface.php b/phpBB/phpbb/auth/provider/interface.php index 480ee4301b..eadd5f01d1 100644 --- a/phpBB/phpbb/auth/provider/interface.php +++ b/phpBB/phpbb/auth/provider/interface.php @@ -45,9 +45,9 @@ interface phpbb_auth_provider_interface * 'error_msg' => string * 'user_row' => array * ) - * A fourth key of the array may be present 'redirect_data' - * This key is only used when 'status' is equal to - * LOGIN_SUCCESS_LINK_PROFILE and it's value is an + * A fourth key of the array may be present: + * 'redirect_data' This key is only used when 'status' is + * equal to LOGIN_SUCCESS_LINK_PROFILE and its value is an * associative array that is turned into GET variables on * the redirect url. */ @@ -89,7 +89,7 @@ interface phpbb_auth_provider_interface * array: 'BLOCK_VAR_NAME'. If this is present, * then its value should be a string that is used * to designate the name of the loop used in the - * ACP template file. In addition to this, an + * ACP template file. When this is present, an * additional key named 'BLOCK_VARS' is required. * This must be an array containing at least one * array of variables that will be assigned during diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index b427ca4e72..c1c27c979f 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -211,8 +211,8 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base // Retrieve the user's account $sql = 'SELECT user_id, username, user_password, user_passchg, user_pass_convert, user_email, user_type, user_login_attempts - FROM ' . $this->users_table . " - WHERE user_id = '" . $this->db->sql_escape($row['user_id']) . "'"; + FROM ' . $this->users_table . ' + WHERE user_id = ' . (int) $row['user_id']; $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); @@ -231,7 +231,9 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base 'error_msg' => false, 'user_row' => $row, ); - } else { + } + else + { $url = $service->getAuthorizationUri(); header('Location: ' . $url); } @@ -291,8 +293,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base if (!$service) { - // Update to an actual error message - throw new Exception('Service not created: ' . $service_name); + throw new Exception('AUTH_PROVIDER_OAUTH_ERROR_SERVICE_NOT_CREATED'); } return $service; @@ -474,7 +475,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base } /** - * Performs the account linking for login_link + * Performs the account linking for auth_link * * @param array $link_data The same variable given to {@see phpbb_auth_provider_interface::link_account} * @param string $service_name The name of the service being used in @@ -503,7 +504,9 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base ); $this->link_account_perform_link($data); - } else { + } + else + { $url = $service->getAuthorizationUri(); header('Location: ' . $url); } diff --git a/phpBB/phpbb/auth/provider/oauth/service/bitly.php b/phpBB/phpbb/auth/provider/oauth/service/bitly.php index 0918f577ec..59e66c7c34 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/bitly.php +++ b/phpBB/phpbb/auth/provider/oauth/service/bitly.php @@ -71,10 +71,10 @@ class phpbb_auth_provider_oauth_service_bitly extends phpbb_auth_provider_oauth_ } // This was a callback request from bitly, get the token - $this->service_provider->requestAccessToken( $this->request->variable('code', '') ); + $this->service_provider->requestAccessToken($this->request->variable('code', '')); // Send a request with it - $result = json_decode( $this->service_provider->request('user/info'), true ); + $result = json_decode($this->service_provider->request('user/info'), true); // Return the unique identifier returned from bitly return $result['data']['login']; @@ -91,7 +91,7 @@ class phpbb_auth_provider_oauth_service_bitly extends phpbb_auth_provider_oauth_ } // Send a request with it - $result = json_decode( $this->service_provider->request('user/info'), true ); + $result = json_decode($this->service_provider->request('user/info'), true); // Return the unique identifier returned from bitly return $result['data']['login']; diff --git a/phpBB/phpbb/auth/provider/oauth/service/facebook.php b/phpBB/phpbb/auth/provider/oauth/service/facebook.php index 836e4ee052..b853c8c8a5 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/facebook.php +++ b/phpBB/phpbb/auth/provider/oauth/service/facebook.php @@ -66,15 +66,14 @@ class phpbb_auth_provider_oauth_service_facebook extends phpbb_auth_provider_oau { if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Facebook)) { - // TODO: make exception class and use language constant throw new Exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); } // This was a callback request, get the token - $this->service_provider->requestAccessToken( $this->request->variable('code', '') ); + $this->service_provider->requestAccessToken($this->request->variable('code', '')); // Send a request with it - $result = json_decode( $this->service_provider->request('/me'), true ); + $result = json_decode($this->service_provider->request('/me'), true); // Return the unique identifier return $result['id']; @@ -87,12 +86,11 @@ class phpbb_auth_provider_oauth_service_facebook extends phpbb_auth_provider_oau { if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Facebook)) { - // TODO: make exception class and use language constant - throw new Exception('Invalid service provider type'); + throw new Exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); } // Send a request with it - $result = json_decode( $this->service_provider->request('/me'), true ); + $result = json_decode($this->service_provider->request('/me'), true); // Return the unique identifier return $result['id']; diff --git a/phpBB/phpbb/auth/provider/oauth/service/google.php b/phpBB/phpbb/auth/provider/oauth/service/google.php index 9c782bcaa0..eb4ad6317a 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/google.php +++ b/phpBB/phpbb/auth/provider/oauth/service/google.php @@ -81,10 +81,10 @@ class phpbb_auth_provider_oauth_service_google extends phpbb_auth_provider_oauth } // This was a callback request, get the token - $this->service_provider->requestAccessToken( $this->request->variable('code', '') ); + $this->service_provider->requestAccessToken($this->request->variable('code', '')); // Send a request with it - $result = json_decode( $this->service_provider->request('https://www.googleapis.com/oauth2/v1/userinfo'), true ); + $result = json_decode($this->service_provider->request('https://www.googleapis.com/oauth2/v1/userinfo'), true); // Return the unique identifier return $result['id']; @@ -101,7 +101,7 @@ class phpbb_auth_provider_oauth_service_google extends phpbb_auth_provider_oauth } // Send a request with it - $result = json_decode( $this->service_provider->request('https://www.googleapis.com/oauth2/v1/userinfo'), true ); + $result = json_decode($this->service_provider->request('https://www.googleapis.com/oauth2/v1/userinfo'), true); // Return the unique identifier return $result['id']; diff --git a/phpBB/phpbb/auth/provider/oauth/token_storage.php b/phpBB/phpbb/auth/provider/oauth/token_storage.php index b31ffcd1ab..05e308d192 100644 --- a/phpBB/phpbb/auth/provider/oauth/token_storage.php +++ b/phpBB/phpbb/auth/provider/oauth/token_storage.php @@ -83,7 +83,8 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface */ public function retrieveAccessToken() { - if( $this->cachedToken instanceOf TokenInterface ) { + if ($this->cachedToken instanceOf TokenInterface) + { return $this->cachedToken; } @@ -92,7 +93,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface 'provider' => $this->service_name, ); - if ($this->user->data['user_id'] == ANONYMOUS) + if ($this->user->data['user_id'] === ANONYMOUS) { $data['session_id'] = $this->user->data['session_id']; } @@ -124,7 +125,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface */ public function hasAccessToken() { - if( $this->cachedToken ) { + if ($this->cachedToken) { return true; } @@ -133,7 +134,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface 'provider' => $this->service_name, ); - if ($this->user->data['user_id'] == ANONYMOUS) + if ($this->user->data['user_id'] === ANONYMOUS) { $data['session_id'] = $this->user->data['session_id']; } @@ -149,12 +150,12 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface $this->cachedToken = null; $sql = 'DELETE FROM ' . $this->auth_provider_oauth_table . ' - WHERE user_id = ' . $this->user->data['user_id'] . ' - AND provider = \'' . $this->db->sql_escape($this->service_name) . '\''; + WHERE user_id = ' . $this->user->data['user_id'] . " + AND provider = '" . $this->db->sql_escape($this->service_name) . "'"; - if ($this->user->data['user_id'] == ANONYMOUS) + if ($this->user->data['user_id'] === ANONYMOUS) { - $sql .= ' AND session_id = \'' . $this->user->data['session_id'] . '\''; + $sql .= " AND session_id = '" . $this->user->data['session_id'] . "'"; } $this->db->sql_query($sql); @@ -176,8 +177,8 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface SET ' . $this->db->sql_build_array('UPDATE', array( 'user_id' => (int) $user_id )) . ' - WHERE user_id = ' . $this->user->data['user_id'] . ' - AND session_id = \'' . $this->user->data['session_id'] . '\''; + WHERE user_id = ' . $this->user->data['user_id'] . " + AND session_id = '" . $this->user->data['session_id'] . "'"; $this->db->sql_query($sql); } @@ -188,7 +189,8 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface */ public function has_access_token_by_session() { - if( $this->cachedToken ) { + if ($this->cachedToken) + { return true; } @@ -208,19 +210,12 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface */ protected function _has_acess_token($data) { - $row = $this->get_access_token_row($data); - - if (!$row) - { - return false; - } - - return true; + return (bool) $this->get_access_token_row($data); } public function retrieve_access_token_by_session() { - if( $this->cachedToken instanceOf TokenInterface ) { + if ($this->cachedToken instanceOf TokenInterface) { return $this->cachedToken; } -- cgit v1.2.1 From d847df717573a55cc6e13211fbe853b4784cf53c Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 24 Aug 2013 22:10:10 -0400 Subject: [feature/oauth] A few more minor changes PHPBB3-11673 --- phpBB/includes/ucp/ucp_register.php | 13 +++++++++++++ phpBB/phpbb/auth/provider/oauth/token_storage.php | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index 8400e98630..e3a1ac1fb0 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -506,6 +506,12 @@ class 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; @@ -525,6 +531,13 @@ class ucp_register 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(); diff --git a/phpBB/phpbb/auth/provider/oauth/token_storage.php b/phpBB/phpbb/auth/provider/oauth/token_storage.php index 05e308d192..c0fce10e17 100644 --- a/phpBB/phpbb/auth/provider/oauth/token_storage.php +++ b/phpBB/phpbb/auth/provider/oauth/token_storage.php @@ -301,7 +301,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface if ($token_data === null) { - throw new TokenNotFoundException('Token not stored correctly'); + throw new TokenNotFoundException('AUTH_PROVIDER_OAUTH_TOKEN_ERROR_INCORRECTLY_STORED'); } $token_class = $token_data['token_class']; -- cgit v1.2.1 From 7f6b2a984927915a70b8e03bbdddd00d73910436 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 24 Aug 2013 22:12:44 -0400 Subject: [feature/oauth] OAuth service exception PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/service/bitly.php | 4 ++-- .../auth/provider/oauth/service/exception.php | 24 ++++++++++++++++++++++ .../phpbb/auth/provider/oauth/service/facebook.php | 4 ++-- phpBB/phpbb/auth/provider/oauth/service/google.php | 4 ++-- .../auth/provider/oauth/service/interface.php | 2 ++ 5 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 phpBB/phpbb/auth/provider/oauth/service/exception.php (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/service/bitly.php b/phpBB/phpbb/auth/provider/oauth/service/bitly.php index 59e66c7c34..3dd33427f6 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/bitly.php +++ b/phpBB/phpbb/auth/provider/oauth/service/bitly.php @@ -67,7 +67,7 @@ class phpbb_auth_provider_oauth_service_bitly extends phpbb_auth_provider_oauth_ if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Bitly)) { // TODO: make exception class and use language constant - throw new Exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); + throw new phpbb_auth_provider_oauth_service_exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); } // This was a callback request from bitly, get the token @@ -87,7 +87,7 @@ class phpbb_auth_provider_oauth_service_bitly extends phpbb_auth_provider_oauth_ { if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Bitly)) { - throw new Exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); + throw new phpbb_auth_provider_oauth_service_exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); } // Send a request with it diff --git a/phpBB/phpbb/auth/provider/oauth/service/exception.php b/phpBB/phpbb/auth/provider/oauth/service/exception.php new file mode 100644 index 0000000000..c2749f571a --- /dev/null +++ b/phpBB/phpbb/auth/provider/oauth/service/exception.php @@ -0,0 +1,24 @@ +service_provider instanceof \OAuth\OAuth2\Service\Facebook)) { - throw new Exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); + throw new phpbb_auth_provider_oauth_service_exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); } // This was a callback request, get the token @@ -86,7 +86,7 @@ class phpbb_auth_provider_oauth_service_facebook extends phpbb_auth_provider_oau { if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Facebook)) { - throw new Exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); + throw new phpbb_auth_provider_oauth_service_exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); } // Send a request with it diff --git a/phpBB/phpbb/auth/provider/oauth/service/google.php b/phpBB/phpbb/auth/provider/oauth/service/google.php index eb4ad6317a..d4ef6e1d42 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/google.php +++ b/phpBB/phpbb/auth/provider/oauth/service/google.php @@ -77,7 +77,7 @@ class phpbb_auth_provider_oauth_service_google extends phpbb_auth_provider_oauth { if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Google)) { - throw new Exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); + throw new phpbb_auth_provider_oauth_service_exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); } // This was a callback request, get the token @@ -97,7 +97,7 @@ class phpbb_auth_provider_oauth_service_google extends phpbb_auth_provider_oauth { if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Google)) { - throw new Exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); + throw new phpbb_auth_provider_oauth_service_exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); } // Send a request with it diff --git a/phpBB/phpbb/auth/provider/oauth/service/interface.php b/phpBB/phpbb/auth/provider/oauth/service/interface.php index 0d6ae7417f..3bba7c0e2c 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/interface.php +++ b/phpBB/phpbb/auth/provider/oauth/service/interface.php @@ -52,6 +52,7 @@ interface phpbb_auth_provider_oauth_service_interface /** * Returns the results of the authentication in json format * + * @throws phpbb_auth_provider_oauth_service_exception * @return string The unique identifier returned by the service provider * that is used to authenticate the user with phpBB. */ @@ -61,6 +62,7 @@ interface phpbb_auth_provider_oauth_service_interface * Returns the results of the authentication in json format * Use this function when the user already has an access token * + * @throws phpbb_auth_provider_oauth_service_exception * @return string The unique identifier returned by the service provider * that is used to authenticate the user with phpBB. */ -- cgit v1.2.1 From 265a3a35526830a351130aa4c15fa15b733005d2 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 24 Aug 2013 22:14:56 -0400 Subject: [feature/oauth] Forgot to remove placeholder comment PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/service/bitly.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/service/bitly.php b/phpBB/phpbb/auth/provider/oauth/service/bitly.php index 3dd33427f6..3bafdd59ce 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/bitly.php +++ b/phpBB/phpbb/auth/provider/oauth/service/bitly.php @@ -66,7 +66,6 @@ class phpbb_auth_provider_oauth_service_bitly extends phpbb_auth_provider_oauth_ { if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Bitly)) { - // TODO: make exception class and use language constant throw new phpbb_auth_provider_oauth_service_exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); } -- cgit v1.2.1 From 2090a5020cec1d0488fa79c31da232517bff775b Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Sat, 24 Aug 2013 22:17:15 -0400 Subject: [feature/oauth] Update comment on oauth service exception PHPBB3-16673 --- phpBB/phpbb/auth/provider/oauth/service/exception.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/service/exception.php b/phpBB/phpbb/auth/provider/oauth/service/exception.php index c2749f571a..23d3387951 100644 --- a/phpBB/phpbb/auth/provider/oauth/service/exception.php +++ b/phpBB/phpbb/auth/provider/oauth/service/exception.php @@ -1,8 +1,8 @@ Date: Mon, 26 Aug 2013 19:56:27 +0100 Subject: [ticket/11803] Revert POLL_MAX_OPTIONS min value to 0 When it was made the min number of options allowed to a user was 1 but 0 can also be used as it means unlimited. PHPBB3-11803 --- phpBB/styles/prosilver/template/posting_poll_body.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/styles/prosilver/template/posting_poll_body.html b/phpBB/styles/prosilver/template/posting_poll_body.html index 5bb7e1a3df..a131c10533 100644 --- a/phpBB/styles/prosilver/template/posting_poll_body.html +++ b/phpBB/styles/prosilver/template/posting_poll_body.html @@ -26,7 +26,7 @@
-
+
{L_POLL_MAX_OPTIONS_EXPLAIN}
-- cgit v1.2.1 From 38a7aac0cceee521fbf2550750a85b4d6bf80ec1 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Wed, 28 Aug 2013 12:29:01 -0500 Subject: [ticket/11724] Handle ELSE IF separately PHPBB3-11724 --- phpBB/phpbb/template/twig/lexer.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index 7cb84167bf..d576316e89 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -221,6 +221,12 @@ class phpbb_template_twig_lexer extends Twig_Lexer */ protected function fix_if_tokens($code) { + // Replace ELSE IF with ELSEIF + $code = preg_replace('##', '', $code); + + // Replace our "div by" with Twig's divisibleby (Twig does not like test names with spaces) + $code = preg_replace('# div by ([0-9]+)#', ' divisibleby($1)', $code); + $callback = function($matches) { $inner = $matches[2]; @@ -233,11 +239,7 @@ class phpbb_template_twig_lexer extends Twig_Lexer return ""; }; - // Replace our "div by" with Twig's divisibleby (Twig does not like test names with spaces) - $code = preg_replace('# div by ([0-9]+)#', ' divisibleby($1)', $code); - - // (ELSE)?\s?IF; match IF|ELSEIF|ELSE IF; replace ELSE IF with ELSEIF - return preg_replace_callback('##', $callback, $code); + return preg_replace_callback('##', $callback, $code); } /** -- cgit v1.2.1 From 0a7508439f20b358f1e51d3f2d8105903588e430 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Wed, 28 Aug 2013 12:39:57 -0500 Subject: [ticket/11373] Use inheritdoc PHPBB3-11373 --- phpBB/phpbb/cron/task/core/prune_notifications.php | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/cron/task/core/prune_notifications.php b/phpBB/phpbb/cron/task/core/prune_notifications.php index 6d38091e9f..296c0ae64f 100644 --- a/phpBB/phpbb/cron/task/core/prune_notifications.php +++ b/phpBB/phpbb/cron/task/core/prune_notifications.php @@ -38,9 +38,7 @@ class phpbb_cron_task_core_prune_notifications extends phpbb_cron_task_base } /** - * Runs this cron task. - * - * @return null + * {@inheritdoc} */ public function run() { @@ -50,9 +48,7 @@ class phpbb_cron_task_core_prune_notifications extends phpbb_cron_task_base } /** - * Returns whether this cron task can run, given current board configuration.= - * - * @return bool + * {@inheritdoc} */ public function is_runnable() { @@ -60,13 +56,7 @@ class phpbb_cron_task_core_prune_notifications extends phpbb_cron_task_base } /** - * Returns whether this cron task should run now, because enough time - * has passed since it was last run. - * - * The interval between prune notifications is specified in board - * configuration. - * - * @return bool + * {@inheritdoc} */ public function should_run() { -- cgit v1.2.1 From aae7677d71112e468b56be7e10d16f3b381fcad7 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Wed, 28 Aug 2013 15:21:35 -0500 Subject: [ticket/11628] Create base template class with common functions E.g. assign_vars PHPBB3-11628 --- phpBB/phpbb/template/base.php | 148 ++++++++++++++++++++++++++++++ phpBB/phpbb/template/twig/twig.php | 180 +------------------------------------ 2 files changed, 149 insertions(+), 179 deletions(-) create mode 100644 phpBB/phpbb/template/base.php (limited to 'phpBB') diff --git a/phpBB/phpbb/template/base.php b/phpBB/phpbb/template/base.php new file mode 100644 index 0000000000..3778424a96 --- /dev/null +++ b/phpBB/phpbb/template/base.php @@ -0,0 +1,148 @@ +filenames = array_merge($this->filenames, $filename_array); + + return $this; + } + + /** + * Get a filename from the handle + * + * @param string $handle + * @return string + */ + protected function get_filename_from_handle($handle) + { + return (isset($this->filenames[$handle])) ? $this->filenames[$handle] : $handle; + } + + /** + * {@inheritdoc} + */ + public function destroy() + { + $this->context->clear(); + + return $this; + } + + /** + * {@inheritdoc} + */ + public function destroy_block_vars($blockname) + { + $this->context->destroy_block_vars($blockname); + + return $this; + } + + /** + * {@inheritdoc} + */ + public function assign_vars(array $vararray) + { + foreach ($vararray as $key => $val) + { + $this->assign_var($key, $val); + } + + return $this; + } + + /** + * {@inheritdoc} + */ + public function assign_var($varname, $varval) + { + $this->context->assign_var($varname, $varval); + + return $this; + } + + /** + * {@inheritdoc} + */ + public function append_var($varname, $varval) + { + $this->context->append_var($varname, $varval); + + return $this; + } + + /** + * {@inheritdoc} + */ + public function assign_block_vars($blockname, array $vararray) + { + $this->context->assign_block_vars($blockname, $vararray); + + return $this; + } + + /** + * {@inheritdoc} + */ + public function alter_block_array($blockname, array $vararray, $key = false, $mode = 'insert') + { + return $this->context->alter_block_array($blockname, $vararray, $key, $mode); + } + + /** + * Calls hook if any is defined. + * + * @param string $handle Template handle being displayed. + * @param string $method Method name of the caller. + */ + protected function call_hook($handle, $method) + { + global $phpbb_hook; + + if (!empty($phpbb_hook) && $phpbb_hook->call_hook(array(__CLASS__, $method), $handle, $this)) + { + if ($phpbb_hook->hook_return(array(__CLASS__, $method))) + { + $result = $phpbb_hook->hook_return_result(array(__CLASS__, $method)); + return array($result); + } + } + + return false; + } +} diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index a96bdcbdb9..1ed89d3ccc 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -19,15 +19,8 @@ if (!defined('IN_PHPBB')) * Twig Template class. * @package phpBB3 */ -class phpbb_template_twig implements phpbb_template +class phpbb_template_twig extends phpbb_template_base { - /** - * Template context. - * Stores template data used during template rendering. - * @var phpbb_template_context - */ - protected $context; - /** * Path of the cache directory for the template * @@ -75,13 +68,6 @@ class phpbb_template_twig implements phpbb_template */ protected $twig; - /** - * Array of filenames assigned to set_filenames - * - * @var array - */ - protected $filenames = array(); - /** * Constructor. * @@ -153,19 +139,6 @@ class phpbb_template_twig implements phpbb_template return $this; } - /** - * Sets the template filenames for handles. - * - * @param array $filename_array Should be a hash of handle => filename pairs. - * @return phpbb_template $this - */ - public function set_filenames(array $filename_array) - { - $this->filenames = array_merge($this->filenames, $filename_array); - - return $this; - } - /** * Get the style tree of the style preferred by the current user * @@ -275,31 +248,6 @@ class phpbb_template_twig implements phpbb_template return $this; } - /** - * Clears all variables and blocks assigned to this template. - * - * @return phpbb_template $this - */ - public function destroy() - { - $this->context->clear(); - - return $this; - } - - /** - * Reset/empty complete block - * - * @param string $blockname Name of block to destroy - * @return phpbb_template $this - */ - public function destroy_block_vars($blockname) - { - $this->context->destroy_block_vars($blockname); - - return $this; - } - /** * Display a template for provided handle. * @@ -323,28 +271,6 @@ class phpbb_template_twig implements phpbb_template return $this; } - /** - * Calls hook if any is defined. - * - * @param string $handle Template handle being displayed. - * @param string $method Method name of the caller. - */ - protected function call_hook($handle, $method) - { - global $phpbb_hook; - - if (!empty($phpbb_hook) && $phpbb_hook->call_hook(array(__CLASS__, $method), $handle, $this)) - { - if ($phpbb_hook->hook_return(array(__CLASS__, $method))) - { - $result = $phpbb_hook->hook_return_result(array(__CLASS__, $method)); - return array($result); - } - } - - return false; - } - /** * Display the handle and assign the output to a template variable * or return the compiled result. @@ -366,99 +292,6 @@ class phpbb_template_twig implements phpbb_template return $this; } - /** - * Assign key variable pairs from an array - * - * @param array $vararray A hash of variable name => value pairs - * @return phpbb_template $this - */ - public function assign_vars(array $vararray) - { - foreach ($vararray as $key => $val) - { - $this->assign_var($key, $val); - } - - return $this; - } - - /** - * Assign a single scalar value to a single key. - * - * Value can be a string, an integer or a boolean. - * - * @param string $varname Variable name - * @param string $varval Value to assign to variable - * @return phpbb_template $this - */ - public function assign_var($varname, $varval) - { - $this->context->assign_var($varname, $varval); - - return $this; - } - - /** - * Append text to the string value stored in a key. - * - * Text is appended using the string concatenation operator (.). - * - * @param string $varname Variable name - * @param string $varval Value to append to variable - * @return phpbb_template $this - */ - public function append_var($varname, $varval) - { - $this->context->append_var($varname, $varval); - - return $this; - } - - /** - * Assign key variable pairs from an array to a specified block - * @param string $blockname Name of block to assign $vararray to - * @param array $vararray A hash of variable name => value pairs - * @return phpbb_template $this - */ - public function assign_block_vars($blockname, array $vararray) - { - $this->context->assign_block_vars($blockname, $vararray); - - return $this; - } - - /** - * Change already assigned key variable pair (one-dimensional - single loop entry) - * - * An example of how to use this function: - * {@example alter_block_array.php} - * - * @param string $blockname the blockname, for example 'loop' - * @param array $vararray the var array to insert/add or merge - * @param mixed $key Key to search for - * - * array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position] - * - * int: Position [the position to change or insert at directly given] - * - * If key is false the position is set to 0 - * If key is true the position is set to the last entry - * - * @param string $mode Mode to execute (valid modes are 'insert' and 'change') - * - * If insert, the vararray is inserted at the given position (position counting from zero). - * If change, the current block gets merged with the vararray (resulting in new key/value pairs be added and existing keys be replaced by the new value). - * - * Since counting begins by zero, inserting at the last position will result in this array: array(vararray, last positioned array) - * and inserting at position 1 will result in this array: array(first positioned array, vararray, following vars) - * - * @return bool false on error, true on success - */ - public function alter_block_array($blockname, array $vararray, $key = false, $mode = 'insert') - { - return $this->context->alter_block_array($blockname, $vararray, $key, $mode); - } - /** * Get template vars in a format Twig will use (from the context) * @@ -483,17 +316,6 @@ class phpbb_template_twig implements phpbb_template return $vars; } - /** - * Get a filename from the handle - * - * @param string $handle - * @return string - */ - protected function get_filename_from_handle($handle) - { - return (isset($this->filenames[$handle])) ? $this->filenames[$handle] : $handle; - } - /** * Get path to template for handle (required for BBCode parser) * -- cgit v1.2.1 From 62e81d174d9d3dbd78baea36425720ed0fdaffb1 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 29 Aug 2013 09:19:14 -0500 Subject: [ticket/11816] Fix define/loop checks in IF statements containing parenthesis PHPBB3-11816 --- phpBB/phpbb/template/twig/lexer.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index 3534311b7a..719066b659 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -223,13 +223,13 @@ class phpbb_template_twig_lexer extends Twig_Lexer { $inner = $matches[2]; // Replace $TEST with definition.TEST - $inner = preg_replace('#\s\$([a-zA-Z_0-9]+)#', ' definition.$1', $inner); + $inner = preg_replace('#(\s\(?!?)\$([a-zA-Z_0-9]+)#', '$1definition.$2', $inner); // Replace .foo with loops.foo|length - $inner = preg_replace('#\s\.([a-zA-Z_0-9]+)([^a-zA-Z_0-9\.])#', ' loops.$1|length$2', $inner); + $inner = preg_replace('#(\s\(?!?)\.([a-zA-Z_0-9]+)([^a-zA-Z_0-9\.])#', '$1loops.$2|length$3', $inner); // Replace .foo.bar with foo.bar|length - $inner = preg_replace('#\s\.([a-zA-Z_0-9\.]+)([^a-zA-Z_0-9\.])#', ' $1|length$2', $inner); + $inner = preg_replace('#(\s\(?!?)\.([a-zA-Z_0-9\.]+)([^a-zA-Z_0-9\.])#', '$1$2|length$3', $inner); return ""; }; @@ -237,7 +237,7 @@ class phpbb_template_twig_lexer extends Twig_Lexer // Replace our "div by" with Twig's divisibleby (Twig does not like test names with spaces) $code = preg_replace('# div by ([0-9]+)#', ' divisibleby($1)', $code); - return preg_replace_callback('##', $callback, $code); + return preg_replace_callback('##', $callback, $code); } /** -- cgit v1.2.1 From 2c4fc9c8bdbedeecb9536fd2f5223512f62a32e1 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 23 May 2013 11:23:19 +0300 Subject: [ticket/11562] Convert marklist() to jQuery PHPBB3-11562 --- phpBB/styles/prosilver/template/forum_fn.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'phpBB') diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index eccb12e827..8f99fe5c60 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -42,19 +42,12 @@ function jumpto() { * id = ID of parent container, name = name prefix, state = state [true/false] */ function marklist(id, name, state) { - var parent = document.getElementById(id) || document[id]; - - if (!parent) { - return; - } - - var rb = parent.getElementsByTagName('input'); - - for (var r = 0; r < rb.length; r++) { - if (rb[r].name.substr(0, name.length) === name) { - rb[r].checked = state; + jQuery('#' + id + ' input[type=checkbox][name]').each(function() { + var $this = jQuery(this); + if ($this.attr('name').substr(0, name.length) == name) { + $this.prop('checked', state); } - } + }); } /** -- cgit v1.2.1 From d091c4f829daae48cc60f735b10c24f666959520 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 23 May 2013 11:27:46 +0300 Subject: [ticket/11562] Remove submit_default_button from forum_fn Remove submit_default_button() and related functions from forum_fn.js PHPBB3-11562 --- phpBB/styles/prosilver/template/forum_fn.js | 92 ----------------------------- 1 file changed, 92 deletions(-) (limited to 'phpBB') diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index 8f99fe5c60..65bc3dedb7 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -248,57 +248,6 @@ function play_qt_file(obj) { obj.Play(); } -/** -* Check if the nodeName of elem is name -* @author jQuery -*/ -function is_node_name(elem, name) { - return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); -} - -/** -* Check if elem is in array, return position -* @author jQuery -*/ -function is_in_array(elem, array) { - for (var i = 0, length = array.length; i < length; i++) { - // === is correct (IE) - if (array[i] === elem) { - return i; - } - } - - return -1; -} - -/** -* Find Element, type and class in tree -* Not used, but may come in handy for those not using JQuery -* @author jQuery.find, Meik Sievertsen -*/ -function find_in_tree(node, tag, type, class_name) { - var result, element, i = 0, length = node.childNodes.length; - - for (element = node.childNodes[0]; i < length; element = node.childNodes[++i]) { - if (!element || element.nodeType !== 1) { - continue; - } - - if ((!tag || is_node_name(element, tag)) && (!type || element.type === type) - && (!class_name || is_in_array(class_name, (element.className || element).toString().split(/\s+/)) > -1)) { - return element; - } - - if (element.childNodes.length) { - result = find_in_tree(element, tag, type, class_name); - } - - if (result) { - return result; - } - } -} - var in_autocomplete = false; var last_key_entered = ''; @@ -329,47 +278,6 @@ function phpbb_check_key(event) { return false; } -/** -* Usually used for onkeypress event, to submit a form on enter -*/ -function submit_default_button(event, selector, class_name) { - // Add which for key events - if (!event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode)) { - event.which = event.charCode || event.keyCode; - } - - if (phpbb_check_key(event)) { - return true; - } - - var current = selector.parentNode; - - // Search parent form element - while (current && (!current.nodeName || current.nodeType !== 1 || !is_node_name(current, 'form')) && current !== document) { - current = current.parentNode; - } - - // Find the input submit button with the class name - //current = find_in_tree(current, 'input', 'submit', class_name); - var input_tags = current.getElementsByTagName('input'); - current = false; - - for (var i = 0, element = input_tags[0]; i < input_tags.length; element = input_tags[++i]) { - if (element.type === 'submit' && is_in_array(class_name, (element.className || element).toString().split(/\s+/)) > -1) { - current = element; - } - } - - if (!current) { - return true; - } - - // Submit form - current.focus(); - current.click(); - return false; -} - /** * Apply onkeypress event for forcing default submit button on ENTER key press * The jQuery snippet used is based on http://greatwebguy.com/programming/dom/default-html-button-submit-on-enter-with-jquery/ -- cgit v1.2.1 From 2624d1ea149eb6582020e90d1ceebf99e45a73f9 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 23 May 2013 12:18:06 +0300 Subject: [ticket/11562] Use jQuery in subPanels PHPBB-11562 --- phpBB/styles/prosilver/template/forum_fn.js | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'phpBB') diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index 65bc3dedb7..4fb8f7b284 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -117,29 +117,15 @@ jQuery(document).ready(function() { } function subPanels(p) { - var i, e, t; + var i; if (typeof(p) === 'string') { show_panel = p; } for (i = 0; i < panels.length; i++) { - e = document.getElementById(panels[i]); - t = document.getElementById(panels[i] + '-tab'); - - if (e) { - if (panels[i] === show_panel) { - e.style.display = 'block'; - if (t) { - t.className = 'activetab'; - } - } else { - e.style.display = 'none'; - if (t) { - t.className = ''; - } - } - } + jQuery('#' + panels[i]).css('display', panels[i] === show_panel ? 'block' : 'none'); + jQuery('#' + panels[i] + '-tab').toggleClass('activetab', panels[i] === show_panel); } } }); -- cgit v1.2.1 From ffee476047a996c1a138bd0050826a7a45c01a94 Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 31 Aug 2013 14:31:50 -0700 Subject: [ticket/11215] Everything appears to be working... PHPBB3-11215 --- phpBB/includes/functions.php | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 428dcfec4a..d85606944f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2413,7 +2413,7 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false) { global $_SID, $_EXTRA_URL, $phpbb_hook; global $phpbb_dispatcher; - global $symfony_request; + global $symfony_request, $phpbb_root_path; if ($params === '' || (is_array($params) && empty($params))) { @@ -2421,10 +2421,10 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false) $params = false; } - $corrected_root = $symfony_request !== null ? phpbb_get_web_root_path($symfony_request) : ''; - if ($corrected_root) + $corrected_path = $symfony_request !== null ? phpbb_get_web_root_path($symfony_request, $phpbb_root_path) : ''; + if ($corrected_path) { - $url = $corrected_root . substr($url, strlen($phpbb_root_path)); + $url = substr($corrected_path . $url, strlen($phpbb_root_path)); } $append_sid_overwrite = false; @@ -5218,7 +5218,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 // This path is sent with the base template paths in the assign_vars() // call below. We need to correct it in case we are accessing from a // controller because the web paths will be incorrect otherwise. - $corrected_path = $symfony_request !== null ? phpbb_get_web_root_path($symfony_request) : ''; + $corrected_path = $symfony_request !== null ? phpbb_get_web_root_path($symfony_request, $phpbb_root_path) : ''; $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $corrected_path; // Send a proper content-language to the output @@ -5731,7 +5731,7 @@ function phpbb_create_symfony_request(phpbb_request $request) * * @param Request $symfony_request Symfony Request object */ -function phpbb_get_web_root_path(Request $symfony_request) +function phpbb_get_web_root_path(Request $symfony_request, $phpbb_root_path = '') { static $path; if (null !== $path) @@ -5740,23 +5740,13 @@ function phpbb_get_web_root_path(Request $symfony_request) } $path_info = $symfony_request->getPathInfo(); - - // When no path is given (i.e. REQUEST_URI = "./app.php") path info from - // the Symfony Request object is "/". However, that is the same as when - // the REQUEST_URI is "./app.php/". So we want to correct the path when - // we have a trailing slash in the REQUEST_URI, but not when we don't. - $request_uri = $symfony_request->server->get('REQUEST_URI'); - $trailing_slash = substr($request_uri, -1) === '/'; - - // If pathinfo is / and we do not have a trailing slash in the REQUEST_URI - if (!$trailing_slash && '/' === $path_info) + if ($path_info === '/') { - $path = ''; + $path = $phpbb_root_path; return $path; } $corrections = substr_count($path_info, '/'); - $path = str_repeat('../', $corrections); - + $path = $phpbb_root_path . str_repeat('../', $corrections); return $path; } -- cgit v1.2.1 From 42b9c3c479a28ba74c214676a17e7e783150e227 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 2 Sep 2013 01:11:40 +0200 Subject: [ticket/11769] Allow '0' as username PHPBB3-11769 --- phpBB/includes/functions_posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 32206df868..11a5067ef9 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -2607,7 +2607,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u // If a username was supplied or the poster is a guest, we will use the supplied username. // Doing it this way we can use "...post by guest-username..." in notifications when // "guest-username" is supplied or ommit the username if it is not. - $username = ($username || !$user->data['is_registered']) ? $username : $user->data['username']; + $username = ($username !== '' || !$user->data['is_registered']) ? $username : $user->data['username']; user_notification($mode, $subject, $data['topic_title'], $data['forum_name'], $data['forum_id'], $data['topic_id'], $data['post_id'], $username); } -- cgit v1.2.1 From cd9711b7c9201fa58ce56e56f85aa2c196bcbdae Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 2 Sep 2013 11:29:50 +0200 Subject: [ticket/11769] Allow using 0 as poster name PHPBB3-11769 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/posting.php b/phpBB/posting.php index 7ab4773df2..61df10b125 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1135,7 +1135,7 @@ if ($submit || $preview || $refresh) // the username was supplied; otherwise post_data might hold the data of the post that is // being quoted (which could result in the username being returned being that of the quoted // post's poster, not the poster of the current post). See: PHPBB3-11769 for more information. - $post_author_name = ((!$user->data['is_registered'] || $mode == 'edit') && $post_data['username']) ? $post_data['username'] : ''; + $post_author_name = ((!$user->data['is_registered'] || $mode == 'edit') && $post_data['username'] !== '') ? $post_data['username'] : ''; // The last parameter tells submit_post if search indexer has to be run $redirect_url = submit_post($mode, $post_data['post_subject'], $post_author_name, $post_data['topic_type'], $poll, $data, $update_message, ($update_message || $update_subject) ? true : false); -- cgit v1.2.1 From 48825975d1e5cb8139757273df8ce9a654efe7bd Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 2 Sep 2013 11:41:31 +0200 Subject: [ticket/11821] Fix comma usage next to "You are receiving this notification". This is a partial backport of 31502cdd6c3a5bac5164ec30530e5b4bf63f3196. PHPBB3-11821 --- phpBB/language/en/email/forum_notify.txt | 2 +- phpBB/language/en/email/newtopic_notify.txt | 2 +- phpBB/language/en/email/topic_notify.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/language/en/email/forum_notify.txt b/phpBB/language/en/email/forum_notify.txt index 490780a0a6..66f3a68689 100644 --- a/phpBB/language/en/email/forum_notify.txt +++ b/phpBB/language/en/email/forum_notify.txt @@ -2,7 +2,7 @@ Subject: Forum post notification - "{FORUM_NAME}" Hello {USERNAME}, -You are receiving this notification because you are watching the forum, "{FORUM_NAME}" at "{SITENAME}". This forum has received a new reply to the topic "{TOPIC_TITLE}" by {AUTHOR_NAME} since your last visit. You can use the following link to view the last unread reply, no more notifications will be sent until you visit the topic. +You are receiving this notification because you are watching the forum "{FORUM_NAME}" at "{SITENAME}". This forum has received a new reply to the topic "{TOPIC_TITLE}" by {AUTHOR_NAME} since your last visit. You can use the following link to view the last unread reply, no more notifications will be sent until you visit the topic. {U_NEWEST_POST} diff --git a/phpBB/language/en/email/newtopic_notify.txt b/phpBB/language/en/email/newtopic_notify.txt index eda1370938..d4f5cae620 100644 --- a/phpBB/language/en/email/newtopic_notify.txt +++ b/phpBB/language/en/email/newtopic_notify.txt @@ -2,7 +2,7 @@ Subject: New topic notification - "{FORUM_NAME}" Hello {USERNAME}, -You are receiving this notification because you are watching the forum, "{FORUM_NAME}" at "{SITENAME}". This forum has received a new topic by {AUTHOR_NAME} since your last visit, "{TOPIC_TITLE}". You can use the following link to view the forum, no more notifications will be sent until you visit the forum. +You are receiving this notification because you are watching the forum "{FORUM_NAME}" at "{SITENAME}". This forum has received a new topic by {AUTHOR_NAME} since your last visit, "{TOPIC_TITLE}". You can use the following link to view the forum, no more notifications will be sent until you visit the forum. {U_FORUM} diff --git a/phpBB/language/en/email/topic_notify.txt b/phpBB/language/en/email/topic_notify.txt index fcfbcc2abd..fa2481dd9a 100644 --- a/phpBB/language/en/email/topic_notify.txt +++ b/phpBB/language/en/email/topic_notify.txt @@ -2,7 +2,7 @@ Subject: Topic reply notification - "{TOPIC_TITLE}" Hello {USERNAME}, -You are receiving this notification because you are watching the topic, "{TOPIC_TITLE}" at "{SITENAME}". This topic has received a reply by {AUTHOR_NAME} since your last visit. You can use the following link to view the replies made, no more notifications will be sent until you visit the topic. +You are receiving this notification because you are watching the topic "{TOPIC_TITLE}" at "{SITENAME}". This topic has received a reply by {AUTHOR_NAME} since your last visit. You can use the following link to view the replies made, no more notifications will be sent until you visit the topic. If you want to view the newest post made since your last visit, click the following link: {U_NEWEST_POST} -- cgit v1.2.1 From 9d48ee446b10e492b83448c3778b48729839b788 Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 2 Sep 2013 09:43:41 -0700 Subject: [ticket/11215] Add commented-out URL rewrite capability to .htaccess PHPBB3-11215 --- phpBB/.htaccess | 30 ++++++++++++++++++++++++++---- phpBB/includes/functions.php | 8 ++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) (limited to 'phpBB') diff --git a/phpBB/.htaccess b/phpBB/.htaccess index 474f9774c2..df17b17d7d 100644 --- a/phpBB/.htaccess +++ b/phpBB/.htaccess @@ -1,12 +1,34 @@ + +# +# Uncomment the following line if you will be using any of the URL +# rewriting below. +# +#RewriteEngine on + # # Uncomment the statement below if you want to make use of # HTTP authentication and it does not already work. # This could be required if you are for example using PHP via Apache CGI. # -# -#RewriteEngine on #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L] -# + +# +# Uncomment the following 3 lines if you want to rewrite URLs passed through +# the front controller to not use app.php in the actual URL. In other words, +# a controller is by default accessed at /app.php/my/controller, but will then +# be accessible at either /app.php/my/controller or just /my/controller +# +#RewriteCond %{REQUEST_FILENAME} !-f +#RewriteCond %{REQUEST_FILENAME} !-d +#RewriteRule ^(.*)$ app.php [QSA,L] + +# +# If symbolic links are not already being followed, +# uncomment the line below. +# http://anothersysadmin.wordpress.com/2008/06/10/mod_rewrite-forbidden-403-with-apache-228/ +# +#Options +FollowSymLinks + Order Allow,Deny @@ -16,4 +38,4 @@ Deny from All Order Allow,Deny Deny from All - + \ No newline at end of file diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index d85606944f..4d2d704a43 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5747,6 +5747,14 @@ function phpbb_get_web_root_path(Request $symfony_request, $phpbb_root_path = '' } $corrections = substr_count($path_info, '/'); + + // When URL Rewriting is enabled, app.php is optional. We have to + // correct for it not being there + if (strpos($symfony_request->getRequestUri(), $symfony_request->getScriptName()) === false) + { + $corrections -= 1; + } + $path = $phpbb_root_path . str_repeat('../', $corrections); return $path; } -- cgit v1.2.1 From 5e86f5687b30397c0e520fd32a9fc92b7e155a16 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 2 Sep 2013 11:25:36 -0500 Subject: [ticket/11727] Template loader support for safe directories to load files from PHPBB3-11727 --- phpBB/phpbb/template/twig/loader.php | 150 +++++++++++++++++++++++++++++++++++ phpBB/phpbb/template/twig/twig.php | 22 +++-- 2 files changed, 165 insertions(+), 7 deletions(-) create mode 100644 phpBB/phpbb/template/twig/loader.php (limited to 'phpBB') diff --git a/phpBB/phpbb/template/twig/loader.php b/phpBB/phpbb/template/twig/loader.php new file mode 100644 index 0000000000..997c05f57c --- /dev/null +++ b/phpBB/phpbb/template/twig/loader.php @@ -0,0 +1,150 @@ +safe_directories = array(); + + if (!empty($directories)) + { + foreach ($directories as $directory) + { + $this->addSafeDirectory($directory); + } + } + + return $this; + } + + /** + * Add safe directory + * + * @param string $directory Directory that should be added + * @return Twig_Loader_Filesystem + */ + public function addSafeDirectory($directory) + { + $directory = phpbb_realpath($directory); + + if ($directory !== false) + { + $this->safe_directories[] = $directory; + } + + return $this; + } + + /** + * Get current safe directories + * + * @return array + */ + public function getSafeDirectories() + { + return $this->safe_directories; + } + + /** + * Override for parent::validateName() + * + * This is done because we added support for safe directories, and when Twig + * findTemplate() is called, validateName() is called first, which would + * always throw an exception if the file is outside of the configured + * template directories. + */ + protected function validateName($name) + { + return; + } + + /** + * Find the template + * + * Override for Twig_Loader_Filesystem::findTemplate to add support + * for loading from safe directories. + */ + protected function findTemplate($name) + { + $name = (string) $name; + + // normalize name + $name = preg_replace('#/{2,}#', '/', strtr($name, '\\', '/')); + + // If this is in the cache we can skip the entire process below + // as it should have already been validated + if (isset($this->cache[$name])) { + return $this->cache[$name]; + } + + // First, find the template name. The override above of validateName + // causes the validateName process to be skipped for this call + $file = parent::findTemplate($name); + + try + { + // Try validating the name (which may throw an exception) + parent::validateName($name); + } + catch (Twig_Error_Loader $e) + { + if (strpos($e->getRawMessage(), 'Looks like you try to load a template outside configured directories') === 0) + { + // Ok, so outside of the configured template directories, we + // can now check if we're within a "safe" directory + + // Find the real path of the directory the file is in + $directory = phpbb_realpath(dirname($file)); + + if ($directory === false) + { + // Some sort of error finding the actual path, must throw the exception + throw $e; + } + + foreach ($this->safe_directories as $safe_directory) + { + if (strpos($directory, $safe_directory) === 0) + { + // The directory being loaded is below a directory + // that is "safe". We're good to load it! + return $file; + } + } + } + + // Not within any safe directories + throw $e; + } + + // No exception from validateName, safe to load. + return $file; + } +} diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 1ed89d3ccc..5746cc64a3 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -91,7 +91,7 @@ class phpbb_template_twig extends phpbb_template_base $this->cachepath = $phpbb_root_path . 'cache/twig/'; // Initiate the loader, __main__ namespace paths will be setup later in set_style_names() - $loader = new Twig_Loader_Filesystem(''); + $loader = new phpbb_template_twig_loader(''); $this->twig = new phpbb_template_twig_environment( $this->config, @@ -181,11 +181,15 @@ class phpbb_template_twig extends phpbb_template_base { foreach ($names as $name) { - $path = $this->phpbb_root_path . trim($directory, '/') . "/{$name}/template/"; + $path = $this->phpbb_root_path . trim($directory, '/') . "/{$name}/"; + $template_path = $path . 'template/'; - if (is_dir($path)) + if (is_dir($template_path)) { - $paths[] = $path; + // Add the base style directory as a safe directory + $this->twig->getLoader()->addSafeDirectory($path); + + $paths[] = $template_path; } } } @@ -233,11 +237,15 @@ class phpbb_template_twig extends phpbb_template_base foreach ($names as $style_name) { - $ext_style_path = $ext_path . 'styles/' . $style_name . '/template'; + $ext_style_path = $ext_path . 'styles/' . $style_name . '/'; + $ext_style_template_path = $ext_style_path . 'template/'; - if (is_dir($ext_style_path)) + if (is_dir($ext_style_template_path)) { - $paths[] = $ext_style_path; + // Add the base style directory as a safe directory + $this->twig->getLoader()->addSafeDirectory($ext_style_path); + + $paths[] = $ext_style_template_path; } } -- cgit v1.2.1 From 913e5a1f2e847c922f8b48e2c069ba204a976e51 Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 2 Sep 2013 10:51:46 -0700 Subject: [ticket/11215] Make controller helper url() method use correct format PHPBB3-11215 --- phpBB/config/services.yml | 1 + phpBB/phpbb/controller/helper.php | 33 +++++++++++++++++---------------- 2 files changed, 18 insertions(+), 16 deletions(-) (limited to 'phpBB') diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index d0753322da..2808e81337 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -90,6 +90,7 @@ services: arguments: - @template - @user + - @request - %core.root_path% - %core.php_ext% diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 74410ddfd1..a14354973e 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -35,6 +35,12 @@ class phpbb_controller_helper */ protected $user; + /** + * Request object + * @var phpbb_request + */ + protected $request; + /** * phpBB root path * @var string @@ -55,10 +61,11 @@ class phpbb_controller_helper * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP extension */ - public function __construct(phpbb_template $template, phpbb_user $user, $phpbb_root_path, $php_ext) + public function __construct(phpbb_template $template, phpbb_user $user, phpbb_request $request, $phpbb_root_path, $php_ext) { $this->template = $template; $this->user = $user; + $this->request = $request; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; } @@ -102,22 +109,16 @@ class phpbb_controller_helper $route = substr($route, 0, $route_delim); } - if (is_array($params) && !empty($params)) - { - $params = array_merge(array( - 'controller' => $route, - ), $params); - } - else if (is_string($params) && $params) - { - $params = 'controller=' . $route . (($is_amp) ? '&' : '&') . $params; - } - else - { - $params = array('controller' => $route); - } + $request_uri = $this->request->variable('REQUEST_URI', '', false, phpbb_request::SERVER); + $script_name = $this->request->variable('SCRIPT_NAME', '', false, phpbb_request::SERVER); + + // If the app.php file is being used (no rewrite) keep it in the URL. + // Otherwise, don't include it. + $route_prefix = $this->phpbb_root_path; + $parts = explode('/', $script_name); + $route_prefix .= strpos($request_uri, $script_name) === 0 ? array_pop($parts) . '/' : ''; - return append_sid($this->phpbb_root_path . 'app.' . $this->php_ext . $route_params, $params, $is_amp, $session_id); + return append_sid($route_prefix . "$route" . $route_params, $params, $is_amp, $session_id); } /** -- cgit v1.2.1 From 1e64095e17ca43273864aa400efed5c7e1fc0ceb Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 2 Sep 2013 11:49:36 -0700 Subject: [ticket/11215] Uncomment rewrite rules in .htaccess Because we check to see if the rewrite module is available we don't have to comment the rewrite lines PHPBB3-11215 --- phpBB/.htaccess | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB') diff --git a/phpBB/.htaccess b/phpBB/.htaccess index df17b17d7d..aaaae0545d 100644 --- a/phpBB/.htaccess +++ b/phpBB/.htaccess @@ -3,7 +3,7 @@ # Uncomment the following line if you will be using any of the URL # rewriting below. # -#RewriteEngine on +RewriteEngine on # # Uncomment the statement below if you want to make use of @@ -18,9 +18,9 @@ # a controller is by default accessed at /app.php/my/controller, but will then # be accessible at either /app.php/my/controller or just /my/controller # -#RewriteCond %{REQUEST_FILENAME} !-f -#RewriteCond %{REQUEST_FILENAME} !-d -#RewriteRule ^(.*)$ app.php [QSA,L] +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^(.*)$ app.php [QSA,L] # # If symbolic links are not already being followed, -- cgit v1.2.1 From 5c50dc721d0f1d7fbfedcbbd573d23751a0504f5 Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 2 Sep 2013 11:51:52 -0700 Subject: [ticket/11215] Update comment in .htaccess PHPBB3-11215 --- phpBB/.htaccess | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB') diff --git a/phpBB/.htaccess b/phpBB/.htaccess index aaaae0545d..a2695ae892 100644 --- a/phpBB/.htaccess +++ b/phpBB/.htaccess @@ -13,10 +13,10 @@ RewriteEngine on #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L] # -# Uncomment the following 3 lines if you want to rewrite URLs passed through -# the front controller to not use app.php in the actual URL. In other words, -# a controller is by default accessed at /app.php/my/controller, but will then -# be accessible at either /app.php/my/controller or just /my/controller +# The following 3 lines will rewrite URLs passed through the front controller +# to not require app.php in the actual URL. In other words, a controller is +# by default accessed at /app.php/my/controller, but can also be accessible +# at /my/controller # RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d -- cgit v1.2.1 From 5ed5f43afea226c421a84c21e486c9f7008c8d49 Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 2 Sep 2013 11:53:52 -0700 Subject: [ticket/11215] Add newline back to .htaccess, fix wording PHPBB3-11215 --- phpBB/.htaccess | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/.htaccess b/phpBB/.htaccess index a2695ae892..80654cf729 100644 --- a/phpBB/.htaccess +++ b/phpBB/.htaccess @@ -15,8 +15,8 @@ RewriteEngine on # # The following 3 lines will rewrite URLs passed through the front controller # to not require app.php in the actual URL. In other words, a controller is -# by default accessed at /app.php/my/controller, but can also be accessible -# at /my/controller +# by default accessed at /app.php/my/controller, but can also be accessed at +# /my/controller # RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d @@ -38,4 +38,4 @@ Deny from All Order Allow,Deny Deny from All - \ No newline at end of file + -- cgit v1.2.1 From 423357581415c7c10ed0ac51284014e839881bac Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 2 Sep 2013 13:54:42 -0500 Subject: [ticket/11822] Use namespace lookup order for asset loading PHPBB3-11822 --- phpBB/phpbb/template/twig/environment.php | 35 +++++++++++++++++++++++++ phpBB/phpbb/template/twig/node/includeasset.php | 4 +-- 2 files changed, 37 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/template/twig/environment.php b/phpBB/phpbb/template/twig/environment.php index b60cd72325..9a40dc2b15 100644 --- a/phpBB/phpbb/template/twig/environment.php +++ b/phpBB/phpbb/template/twig/environment.php @@ -137,4 +137,39 @@ class phpbb_template_twig_environment extends Twig_Environment return parent::loadTemplate($name, $index); } } + + /** + * Finds a template by name. + * + * @param string $name The template name + * @return string + */ + public function findTemplate($name) + { + if (strpos($name, '@') === false) + { + foreach ($this->getNamespaceLookUpOrder() as $namespace) + { + try + { + if ($namespace === '__main__') + { + return parent::getLoader()->getCacheKey($name); + } + + return parent::getLoader()->getCacheKey('@' . $namespace . '/' . $name); + } + catch (Twig_Error_Loader $e) + { + } + } + + // We were unable to load any templates + throw $e; + } + else + { + return parent::getLoader()->getCacheKey($name); + } + } } diff --git a/phpBB/phpbb/template/twig/node/includeasset.php b/phpBB/phpbb/template/twig/node/includeasset.php index 1cab416c79..0808e2b10e 100644 --- a/phpBB/phpbb/template/twig/node/includeasset.php +++ b/phpBB/phpbb/template/twig/node/includeasset.php @@ -40,10 +40,10 @@ abstract class phpbb_template_twig_node_includeasset extends Twig_Node ->write("\$local_file = \$this->getEnvironment()->get_phpbb_root_path() . \$asset_path;\n") ->write("if (!file_exists(\$local_file)) {\n") ->indent() - ->write("\$local_file = \$this->getEnvironment()->getLoader()->getCacheKey(\$asset_path);\n") + ->write("\$local_file = \$this->getEnvironment()->findTemplate(\$asset_path);\n") ->write("\$asset->set_path(\$local_file, true);\n") ->outdent() - ->write("\$asset->add_assets_version({$config['assets_version']});\n") + ->write("\$asset->add_assets_version('{$config['assets_version']}');\n") ->write("\$asset_file = \$asset->get_url();\n") ->write("}\n") ->outdent() -- cgit v1.2.1 From a1b4c6f82a01591a121d47d32c57b93870aa946a Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 2 Sep 2013 12:53:37 -0700 Subject: [ticket/11215] Fix helper_url_test.php tests PHPBB3-11215 --- phpBB/phpbb/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index a14354973e..4d240f9380 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -61,7 +61,7 @@ class phpbb_controller_helper * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP extension */ - public function __construct(phpbb_template $template, phpbb_user $user, phpbb_request $request, $phpbb_root_path, $php_ext) + public function __construct(phpbb_template $template, phpbb_user $user, phpbb_request_interface $request, $phpbb_root_path, $php_ext) { $this->template = $template; $this->user = $user; -- cgit v1.2.1 From d04def0558581e97b608a505f9e5a21557bc47fa Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 2 Sep 2013 15:19:13 -0400 Subject: [feature/oauth] Update lusitanian/oauth to stable branch PHPBB3-11673 --- phpBB/composer.json | 2 +- phpBB/composer.lock | 42 ++++++++++++++++++++++++++---------------- 2 files changed, 27 insertions(+), 17 deletions(-) (limited to 'phpBB') diff --git a/phpBB/composer.json b/phpBB/composer.json index 20fe42735b..b4fad5a529 100644 --- a/phpBB/composer.json +++ b/phpBB/composer.json @@ -1,7 +1,7 @@ { "minimum-stability": "beta", "require": { - "lusitanian/oauth": "0.1.*@dev", + "lusitanian/oauth": "0.2.*", "symfony/config": "2.1.*", "symfony/dependency-injection": "2.1.*", "symfony/event-dispatcher": "2.1.*", diff --git a/phpBB/composer.lock b/phpBB/composer.lock index 4bd73be2fe..d1b90c3a3a 100644 --- a/phpBB/composer.lock +++ b/phpBB/composer.lock @@ -3,28 +3,34 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "2b416686326d0308f977924abc825639", + "hash": "1be626fe7a2e4d450a6e8d67b9a31fb4", "packages": [ { "name": "lusitanian/oauth", - "version": "dev-master", + "version": "v0.2.1", "source": { "type": "git", "url": "https://github.com/Lusitanian/PHPoAuthLib.git", - "reference": "b7e96d0c36f17aa8a217b6be897363bb2cc93286" + "reference": "00c667d93058e983fc1b7d3d1cebdb1bc03fb043" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Lusitanian/PHPoAuthLib/zipball/b7e96d0c36f17aa8a217b6be897363bb2cc93286", - "reference": "b7e96d0c36f17aa8a217b6be897363bb2cc93286", + "url": "https://api.github.com/repos/Lusitanian/PHPoAuthLib/zipball/00c667d93058e983fc1b7d3d1cebdb1bc03fb043", + "reference": "00c667d93058e983fc1b7d3d1cebdb1bc03fb043", "shasum": "" }, "require": { "php": ">=5.3.0" }, "require-dev": { + "phpunit/phpunit": "3.7.*", + "predis/predis": "0.8.*@dev", "symfony/http-foundation": "~2.1" }, + "suggest": { + "predis/predis": "Allows using the Redis storage backend.", + "symfony/http-foundation": "Allows using the Symfony Session storage backend." + }, "type": "library", "extra": { "branch-alias": { @@ -33,7 +39,8 @@ }, "autoload": { "psr-0": { - "OAuth": "src" + "OAuth": "src", + "OAuth\\Unit": "tests" } }, "notification-url": "https://packagist.org/downloads/", @@ -47,7 +54,9 @@ }, { "name": "Pieter Hordijk", - "email": "info@pieterhordijk.com" + "email": "info@pieterhordijk.com", + "homepage": "https://pieterhordijk.com", + "role": "developer" } ], "description": "PHP 5.3+ oAuth 1/2 Library", @@ -57,7 +66,7 @@ "oauth", "security" ], - "time": "2013-07-12 12:56:37" + "time": "2013-08-29 21:40:04" }, { "name": "symfony/config", @@ -199,17 +208,17 @@ }, { "name": "symfony/http-foundation", - "version": "v2.1.11", + "version": "v2.1.12", "target-dir": "Symfony/Component/HttpFoundation", "source": { "type": "git", "url": "https://github.com/symfony/HttpFoundation.git", - "reference": "v2.1.11" + "reference": "79fd1ab0b85e782d342e83799b39b729fd1a30ee" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/v2.1.11", - "reference": "v2.1.11", + "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/79fd1ab0b85e782d342e83799b39b729fd1a30ee", + "reference": "79fd1ab0b85e782d342e83799b39b729fd1a30ee", "shasum": "" }, "require": { @@ -222,6 +231,7 @@ "SessionHandlerInterface": "Symfony/Component/HttpFoundation/Resources/stubs" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -237,7 +247,7 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "http://symfony.com", - "time": "2013-05-26 18:42:07" + "time": "2013-08-07 13:58:42" }, { "name": "symfony/http-kernel", @@ -1288,9 +1298,9 @@ ], "minimum-stability": "beta", - "stability-flags": { - "lusitanian/oauth": 20 - }, + "stability-flags": [ + + ], "platform": [ ], -- cgit v1.2.1 From 6df2bd4fd3e9babc6a79e4f03d6d5a20d79940f8 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 2 Sep 2013 15:25:38 -0400 Subject: [feature/oauth] Update storage implementation due to inteface change PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 2 +- phpBB/phpbb/auth/provider/oauth/token_storage.php | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index c1c27c979f..142c209c0a 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -613,7 +613,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base // Clear all tokens belonging to the user on this servce $service_name = 'auth.provider.oauth.service.' . strtolower($link_data['oauth_service']); $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_token_storage_table); - $storage->clearToken(); + $storage->clearToken($service_name); return; } diff --git a/phpBB/phpbb/auth/provider/oauth/token_storage.php b/phpBB/phpbb/auth/provider/oauth/token_storage.php index c0fce10e17..96f2e2fb0a 100644 --- a/phpBB/phpbb/auth/provider/oauth/token_storage.php +++ b/phpBB/phpbb/auth/provider/oauth/token_storage.php @@ -145,13 +145,31 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface /** * {@inheritdoc} */ - public function clearToken() + public function clearToken($service) { $this->cachedToken = null; $sql = 'DELETE FROM ' . $this->auth_provider_oauth_table . ' WHERE user_id = ' . $this->user->data['user_id'] . " - AND provider = '" . $this->db->sql_escape($this->service_name) . "'"; + AND provider = '" . $this->db->sql_escape($service) . "'"; + + if ($this->user->data['user_id'] === ANONYMOUS) + { + $sql .= " AND session_id = '" . $this->user->data['session_id'] . "'"; + } + + $this->db->sql_query($sql); + } + + /** + * {@inheritdoc} + */ + public function clearAllTokens() + { + $this->cachedToken = null; + + $sql = 'DELETE FROM ' . $this->auth_provider_oauth_table . ' + WHERE user_id = ' . $this->user->data['user_id']; if ($this->user->data['user_id'] === ANONYMOUS) { -- cgit v1.2.1 From a2be0aab5f21ee7efe7d765b08853231a38fcf72 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 2 Sep 2013 15:27:57 -0400 Subject: [feature/oauth] Update oauth::logout() to use clearAllTokens() PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 142c209c0a..a5709d8ff6 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -530,10 +530,8 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base public function logout($data, $new_session) { // Clear all tokens belonging to the user - $sql = 'DELETE FROM ' . $this->auth_provider_oauth_token_storage_table . " - WHERE session_id = '" . $this->db->sql_escape($this->user->session_id) . "' - AND user_id = " . (int) $this->user->data['user_id']; - $this->db->sql_query($sql); + $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, '', $this->auth_provider_oauth_token_storage_table); + $stroage->clearAllTokens(); return; } -- cgit v1.2.1 From 4348fd83501a56338c1584d96da91b1d6945b93b Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 2 Sep 2013 15:32:42 -0400 Subject: [feature/oauth] Make token storage service ignorant PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 12 ++++----- phpBB/phpbb/auth/provider/oauth/token_storage.php | 31 ++++++++--------------- 2 files changed, 17 insertions(+), 26 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index a5709d8ff6..5df7db726b 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -175,7 +175,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base // Get the service credentials for the given service $service_credentials = $this->service_providers[$service_name]->get_service_credentials(); - $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_token_storage_table); + $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $this->auth_provider_oauth_token_storage_table); $query = 'mode=login&login=external&oauth_service=' . $service_name_original; $service = $this->get_service($service_name_original, $storage, $service_credentials, $this->service_providers[$service_name]->get_auth_scope(), $query); @@ -442,10 +442,10 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base */ protected function link_account_login_link(array $link_data, $service_name) { - $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_token_storage_table); + $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $this->auth_provider_oauth_token_storage_table); // Check for an access token, they should have one - if (!$storage->has_access_token_by_session()) + if (!$storage->has_access_token_by_session($service_name)) { return 'LOGIN_LINK_ERROR_OAUTH_NO_ACCESS_TOKEN'; } @@ -485,7 +485,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base */ protected function link_account_auth_link(array $link_data, $service_name) { - $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_token_storage_table); + $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $this->auth_provider_oauth_token_storage_table); $query = 'i=ucp_auth_link&mode=auth_link&link=1&oauth_service=' . strtolower($link_data['oauth_service']); $service_credentials = $this->service_providers[$service_name]->get_service_credentials(); $scopes = $this->service_providers[$service_name]->get_auth_scope(); @@ -530,7 +530,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base public function logout($data, $new_session) { // Clear all tokens belonging to the user - $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, '', $this->auth_provider_oauth_token_storage_table); + $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $this->auth_provider_oauth_token_storage_table); $stroage->clearAllTokens(); return; @@ -610,7 +610,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base // Clear all tokens belonging to the user on this servce $service_name = 'auth.provider.oauth.service.' . strtolower($link_data['oauth_service']); - $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $service_name, $this->auth_provider_oauth_token_storage_table); + $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $this->auth_provider_oauth_token_storage_table); $storage->clearToken($service_name); return; diff --git a/phpBB/phpbb/auth/provider/oauth/token_storage.php b/phpBB/phpbb/auth/provider/oauth/token_storage.php index 96f2e2fb0a..15f491c9dc 100644 --- a/phpBB/phpbb/auth/provider/oauth/token_storage.php +++ b/phpBB/phpbb/auth/provider/oauth/token_storage.php @@ -43,13 +43,6 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface */ protected $user; - /** - * Name of the OAuth provider - * - * @var string - */ - protected $service_name; - /** * OAuth token table * @@ -67,21 +60,19 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface * * @param phpbb_db_driver $db * @param phpbb_user $user - * @param string $service_name * @param string $auth_provider_oauth_table */ - public function __construct(phpbb_db_driver $db, phpbb_user $user, $service_name, $auth_provider_oauth_table) + public function __construct(phpbb_db_driver $db, phpbb_user $user, $auth_provider_oauth_table) { $this->db = $db; $this->user = $user; - $this->service_name = $service_name; $this->auth_provider_oauth_table = $auth_provider_oauth_table; } /** * {@inheritdoc} */ - public function retrieveAccessToken() + public function retrieveAccessToken($service) { if ($this->cachedToken instanceOf TokenInterface) { @@ -90,7 +81,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface $data = array( 'user_id' => $this->user->data['user_id'], - 'provider' => $this->service_name, + 'provider' => $service, ); if ($this->user->data['user_id'] === ANONYMOUS) @@ -104,13 +95,13 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface /** * {@inheritdoc} */ - public function storeAccessToken(TokenInterface $token) + public function storeAccessToken($service, TokenInterface $token) { $this->cachedToken = $token; $data = array( 'user_id' => $this->user->data['user_id'], - 'provider' => $this->service_name, + 'provider' => $service, 'oauth_token' => $this->json_encode_token($token), 'session_id' => $this->user->data['session_id'], ); @@ -123,7 +114,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface /** * {@inheritdoc} */ - public function hasAccessToken() + public function hasAccessToken($service) { if ($this->cachedToken) { return true; @@ -131,7 +122,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface $data = array( 'user_id' => $this->user->data['user_id'], - 'provider' => $this->service_name, + 'provider' => $service, ); if ($this->user->data['user_id'] === ANONYMOUS) @@ -205,7 +196,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface * * @return bool true if they have token, false if they don't */ - public function has_access_token_by_session() + public function has_access_token_by_session($service) { if ($this->cachedToken) { @@ -214,7 +205,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface $data = array( 'session_id' => $this->user->data['session_id'], - 'provider' => $this->service_name, + 'provider' => $service, ); return $this->_has_acess_token($data); @@ -231,7 +222,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface return (bool) $this->get_access_token_row($data); } - public function retrieve_access_token_by_session() + public function retrieve_access_token_by_session($service) { if ($this->cachedToken instanceOf TokenInterface) { return $this->cachedToken; @@ -239,7 +230,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface $data = array( 'session_id' => $this->user->data['session_id'], - 'provider' => $this->service_name, + 'provider' => $service, ); return $this->_retrieve_access_token($data); -- cgit v1.2.1 From 6420fdcc053aa1bfa0e612586a1d4f18a5172e74 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 2 Sep 2013 15:55:23 -0400 Subject: [feature/oauth] Fix typo in OAuth logout method PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/oauth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 5df7db726b..a0bc3038cb 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -531,7 +531,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base { // Clear all tokens belonging to the user $storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $this->auth_provider_oauth_token_storage_table); - $stroage->clearAllTokens(); + $storage->clearAllTokens(); return; } -- cgit v1.2.1 From 51f06f36f1f90429b48cab473f0eaf2b57b1b811 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 2 Sep 2013 16:31:09 -0400 Subject: [feature/oauth] Fix small issues on ucp pages PHPBB3-11673 --- phpBB/includes/ucp/ucp_auth_link.php | 2 +- phpBB/includes/ucp/ucp_login_link.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_auth_link.php b/phpBB/includes/ucp/ucp_auth_link.php index 4fa984c9e7..ed348609cf 100644 --- a/phpBB/includes/ucp/ucp_auth_link.php +++ b/phpBB/includes/ucp/ucp_auth_link.php @@ -1,7 +1,7 @@ variable_names(phpbb_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 = str_replace('login_link_', '', $var_name); + $key_name = substr($var_name, $string_start_length); $login_link_data[$key_name] = $request->variable($var_name, '', false, phpbb_request_interface::GET); } } -- cgit v1.2.1 From 63ba06406575b5c7882ef26ee3b5469ca16afec5 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 2 Sep 2013 16:32:24 -0400 Subject: [feature/oauth] Fix small bug introduced by update in OAuth library PHPBB3-11673 --- phpBB/phpbb/auth/provider/oauth/token_storage.php | 30 +++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'phpBB') diff --git a/phpBB/phpbb/auth/provider/oauth/token_storage.php b/phpBB/phpbb/auth/provider/oauth/token_storage.php index 15f491c9dc..f9ba28ee69 100644 --- a/phpBB/phpbb/auth/provider/oauth/token_storage.php +++ b/phpBB/phpbb/auth/provider/oauth/token_storage.php @@ -74,6 +74,8 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface */ public function retrieveAccessToken($service) { + $service = $this->get_service_name_for_db($service); + if ($this->cachedToken instanceOf TokenInterface) { return $this->cachedToken; @@ -97,6 +99,8 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface */ public function storeAccessToken($service, TokenInterface $token) { + $service = $this->get_service_name_for_db($service); + $this->cachedToken = $token; $data = array( @@ -116,6 +120,8 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface */ public function hasAccessToken($service) { + $service = $this->get_service_name_for_db($service); + if ($this->cachedToken) { return true; } @@ -138,6 +144,8 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface */ public function clearToken($service) { + $service = $this->get_service_name_for_db($service); + $this->cachedToken = null; $sql = 'DELETE FROM ' . $this->auth_provider_oauth_table . ' @@ -198,6 +206,8 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface */ public function has_access_token_by_session($service) { + $service = $this->get_service_name_for_db($service); + if ($this->cachedToken) { return true; @@ -224,6 +234,8 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface public function retrieve_access_token_by_session($service) { + $service = $this->get_service_name_for_db($service); + if ($this->cachedToken instanceOf TokenInterface) { return $this->cachedToken; } @@ -333,4 +345,22 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface return $token; } + + /** + * Returns the name of the service as it must be stored in the database. + * + * @param string $service The name of the OAuth service + * @return string The name of the OAuth service as it needs to be stored + * in the database. + */ + protected function get_service_name_for_db($service) + { + // Enforce the naming convention for oauth services + if (strpos($service, 'auth.provider.oauth.service.') !== 0) + { + $service = 'auth.provider.oauth.service.' . strtolower($service); + } + + return $service; + } } -- cgit v1.2.1 From 29e3768ecc7bc8adf96d4e31c4e05a6f1de6735a Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 2 Sep 2013 16:47:40 -0400 Subject: [feature/oauth] More minor changes from review PHPBB3-11673 --- phpBB/includes/ucp/ucp_login_link.php | 4 ++-- phpBB/includes/ucp/ucp_register.php | 5 +++-- phpBB/phpbb/auth/auth.php | 2 +- phpBB/phpbb/auth/provider/oauth/oauth.php | 6 +++--- phpBB/phpbb/auth/provider/oauth/token_storage.php | 26 +++++++++++------------ 5 files changed, 22 insertions(+), 21 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_login_link.php b/phpBB/includes/ucp/ucp_login_link.php index bf7df1d4eb..4620eb9b9e 100644 --- a/phpBB/includes/ucp/ucp_login_link.php +++ b/phpBB/includes/ucp/ucp_login_link.php @@ -236,8 +236,8 @@ class ucp_login_link */ protected function perform_redirect() { - global $phpEx; - $url = append_sid('index.' . $phpEx); + global $phpbb_root_path, $phpEx; + $url = append_sid($phpbb_root_path . 'index.' . $phpEx); redirect($url); } } diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index e3a1ac1fb0..372eecbb57 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -86,7 +86,7 @@ class ucp_register // Handle login_link data added to $_hidden_fields $login_link_data = $this->get_login_link_data_array(); - if ($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']); @@ -518,12 +518,13 @@ class ucp_register $var_names = $request->variable_names(phpbb_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 = str_replace('login_link_', '', $var_name); + $key_name = substr($var_name, $string_start_length); $login_link_data[$key_name] = $request->variable($var_name, '', false, phpbb_request_interface::POST); } } diff --git a/phpBB/phpbb/auth/auth.php b/phpBB/phpbb/auth/auth.php index 5093483d4a..81f8c76fc8 100644 --- a/phpBB/phpbb/auth/auth.php +++ b/phpBB/phpbb/auth/auth.php @@ -977,7 +977,7 @@ class phpbb_auth // This data is passed along as GET data to the next page allow the account to be linked $params = array('mode' => 'login_link'); - $url = append_sid('ucp.' . $phpEx, array_merge($params, $login['redirect_data'])); + $url = append_sid($phpbb_root_path . 'ucp.' . $phpEx, array_merge($params, $login['redirect_data'])); redirect($url); } diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index a0bc3038cb..be0b8bb7d6 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -211,8 +211,8 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base // Retrieve the user's account $sql = 'SELECT user_id, username, user_password, user_passchg, user_pass_convert, user_email, user_type, user_login_attempts - FROM ' . $this->users_table . ' - WHERE user_id = ' . (int) $row['user_id']; + FROM ' . $this->users_table . ' + WHERE user_id = ' . (int) $row['user_id']; $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); @@ -545,7 +545,7 @@ class phpbb_auth_provider_oauth extends phpbb_auth_provider_base // Get all external accounts tied to the current user $data = array( - 'user_id' => $this->user->data['user_id'], + 'user_id' => (int) $this->user->data['user_id'], ); $sql = 'SELECT oauth_provider_id, provider FROM ' . $this->auth_provider_oauth_token_account_assoc . ' WHERE ' . $this->db->sql_build_array('SELECT', $data); diff --git a/phpBB/phpbb/auth/provider/oauth/token_storage.php b/phpBB/phpbb/auth/provider/oauth/token_storage.php index f9ba28ee69..d21deb8999 100644 --- a/phpBB/phpbb/auth/provider/oauth/token_storage.php +++ b/phpBB/phpbb/auth/provider/oauth/token_storage.php @@ -82,11 +82,11 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface } $data = array( - 'user_id' => $this->user->data['user_id'], + 'user_id' => (int) $this->user->data['user_id'], 'provider' => $service, ); - if ($this->user->data['user_id'] === ANONYMOUS) + if ((int) $this->user->data['user_id'] === ANONYMOUS) { $data['session_id'] = $this->user->data['session_id']; } @@ -104,7 +104,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface $this->cachedToken = $token; $data = array( - 'user_id' => $this->user->data['user_id'], + 'user_id' => (int) $this->user->data['user_id'], 'provider' => $service, 'oauth_token' => $this->json_encode_token($token), 'session_id' => $this->user->data['session_id'], @@ -127,11 +127,11 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface } $data = array( - 'user_id' => $this->user->data['user_id'], + 'user_id' => (int) $this->user->data['user_id'], 'provider' => $service, ); - if ($this->user->data['user_id'] === ANONYMOUS) + if ((int) $this->user->data['user_id'] === ANONYMOUS) { $data['session_id'] = $this->user->data['session_id']; } @@ -149,12 +149,12 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface $this->cachedToken = null; $sql = 'DELETE FROM ' . $this->auth_provider_oauth_table . ' - WHERE user_id = ' . $this->user->data['user_id'] . " + WHERE user_id = ' . (int) $this->user->data['user_id'] . " AND provider = '" . $this->db->sql_escape($service) . "'"; - if ($this->user->data['user_id'] === ANONYMOUS) + if ((int) $this->user->data['user_id'] === ANONYMOUS) { - $sql .= " AND session_id = '" . $this->user->data['session_id'] . "'"; + $sql .= " AND session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "'"; } $this->db->sql_query($sql); @@ -168,11 +168,11 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface $this->cachedToken = null; $sql = 'DELETE FROM ' . $this->auth_provider_oauth_table . ' - WHERE user_id = ' . $this->user->data['user_id']; + WHERE user_id = ' . (int) $this->user->data['user_id']; - if ($this->user->data['user_id'] === ANONYMOUS) + if ((int) $this->user->data['user_id'] === ANONYMOUS) { - $sql .= " AND session_id = '" . $this->user->data['session_id'] . "'"; + $sql .= " AND session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "'"; } $this->db->sql_query($sql); @@ -194,8 +194,8 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface SET ' . $this->db->sql_build_array('UPDATE', array( 'user_id' => (int) $user_id )) . ' - WHERE user_id = ' . $this->user->data['user_id'] . " - AND session_id = '" . $this->user->data['session_id'] . "'"; + WHERE user_id = ' . (int) $this->user->data['user_id'] . " + AND session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "'"; $this->db->sql_query($sql); } -- cgit v1.2.1 From 8ee86b75908141c28aa4d92ba93921337cde30c3 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Wed, 28 Aug 2013 13:40:35 -0500 Subject: [ticket/11791] Load adm/ events from styles/adm/event/ PHPBB3-11791 --- phpBB/adm/index.php | 2 +- phpBB/adm/swatch.php | 2 +- phpBB/includes/functions_module.php | 2 +- phpBB/install/index.php | 2 +- phpBB/install/install_update.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB') diff --git a/phpBB/adm/index.php b/phpBB/adm/index.php index 3520eb8b70..c1e8edbd03 100644 --- a/phpBB/adm/index.php +++ b/phpBB/adm/index.php @@ -50,7 +50,7 @@ $module_id = request_var('i', ''); $mode = request_var('mode', ''); // Set custom style for admin area -$template->set_custom_style('admin', $phpbb_admin_path . 'style'); +$template->set_custom_style('adm', $phpbb_admin_path . 'style'); $template->assign_var('T_ASSETS_PATH', $phpbb_root_path . 'assets'); $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style'); diff --git a/phpBB/adm/swatch.php b/phpBB/adm/swatch.php index cdd6bf3969..e9d46d65b5 100644 --- a/phpBB/adm/swatch.php +++ b/phpBB/adm/swatch.php @@ -22,7 +22,7 @@ $auth->acl($user->data); $user->setup(); // Set custom template for admin area -$template->set_custom_style('admin', $phpbb_admin_path . 'style'); +$template->set_custom_style('adm', $phpbb_admin_path . 'style'); $template->set_filenames(array( 'body' => 'colour_swatch.html') diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index 8f0f6a837a..80477684a8 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -508,7 +508,7 @@ class p_master if (is_dir($module_style_dir)) { - $template->set_custom_style('admin', array($module_style_dir, $phpbb_admin_path . 'style')); + $template->set_custom_style('adm', array($module_style_dir, $phpbb_admin_path . 'style')); } } diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 530728bdba..ec9aa5f32a 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -247,7 +247,7 @@ $config = new phpbb_config(array( $template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context()); $paths = array($phpbb_root_path . 'install/update/new/adm/style', $phpbb_admin_path . 'style'); $paths = array_filter($paths, 'is_dir'); -$template->set_custom_style('admin', $paths); +$template->set_custom_style('adm', $paths); $template->assign_var('T_ASSETS_PATH', '../assets'); $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style'); diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index a569e0ad9a..8ab0ad49d3 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -143,7 +143,7 @@ class install_update extends module // Set custom template again. ;) $paths = array($phpbb_root_path . 'install/update/new/adm/style', $phpbb_admin_path . 'style'); $paths = array_filter($paths, 'is_dir'); - $template->set_custom_style('admin', $paths); + $template->set_custom_style('adm', $paths); $template->assign_vars(array( 'S_USER_LANG' => $user->lang['USER_LANG'], -- cgit v1.2.1 From ae18f921ea61b20b026c4679b5b27cf40825f5dd Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 2 Sep 2013 16:52:24 -0400 Subject: [feature/oauth] More small fixes PHPBB3-11673 --- phpBB/includes/ucp/ucp_register.php | 2 +- phpBB/styles/prosilver/template/login_body_oauth.html | 2 +- phpBB/styles/prosilver/template/ucp_login_link.html | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index 372eecbb57..0c49cd1a5c 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -417,7 +417,7 @@ class ucp_register } // Perform account linking if necessary - if ($login_link_data !== array()) + if (!empty($login_link_data)) { $login_link_data['user_id'] = $user_id; diff --git a/phpBB/styles/prosilver/template/login_body_oauth.html b/phpBB/styles/prosilver/template/login_body_oauth.html index dbbe011c58..156485d211 100644 --- a/phpBB/styles/prosilver/template/login_body_oauth.html +++ b/phpBB/styles/prosilver/template/login_body_oauth.html @@ -4,5 +4,5 @@
 
{oauth.SERVICE_NAME}
- + diff --git a/phpBB/styles/prosilver/template/ucp_login_link.html b/phpBB/styles/prosilver/template/ucp_login_link.html index baf7d56176..d3c6931ce3 100644 --- a/phpBB/styles/prosilver/template/ucp_login_link.html +++ b/phpBB/styles/prosilver/template/ucp_login_link.html @@ -18,7 +18,7 @@
 
-
{S_HIDDEN_FIELDS}
+
{S_HIDDEN_FIELDS}
@@ -32,21 +32,21 @@
{LOGIN_ERROR}
-
+
-
+
- + {S_LOGIN_REDIRECT}
 
-
{S_HIDDEN_FIELDS}
+
{S_HIDDEN_FIELDS}
-- cgit v1.2.1 From d5808f13e5fa70ecc802c2a5a11c3143746c93f0 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Mon, 2 Sep 2013 16:54:14 -0400 Subject: [feature/oauth] Fix bug on ucp_auth_link related to error display PHPBB3-11673 --- phpBB/includes/ucp/ucp_auth_link.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB') diff --git a/phpBB/includes/ucp/ucp_auth_link.php b/phpBB/includes/ucp/ucp_auth_link.php index ed348609cf..5a5653e0b2 100644 --- a/phpBB/includes/ucp/ucp_auth_link.php +++ b/phpBB/includes/ucp/ucp_auth_link.php @@ -125,6 +125,7 @@ class ucp_auth_link // Replace "error" strings with their real, localised form $error = array_map(array($user, 'lang'), $error); + $error = implode('
', $error); $template->assign_vars(array( 'ERROR' => $error, -- cgit v1.2.1 From fe6688ff49ade1de81ac44a378973ce7960f64c0 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 2 Sep 2013 16:18:29 -0500 Subject: [ticket/11818] Update Symfony dependencies to 2.3.* PHPBB3-11818 --- phpBB/composer.json | 12 +- phpBB/composer.lock | 497 ++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 349 insertions(+), 160 deletions(-) (limited to 'phpBB') diff --git a/phpBB/composer.json b/phpBB/composer.json index bf693d1950..a4bf8bf977 100644 --- a/phpBB/composer.json +++ b/phpBB/composer.json @@ -1,12 +1,12 @@ { "minimum-stability": "beta", "require": { - "symfony/config": "2.1.*", - "symfony/dependency-injection": "2.1.*", - "symfony/event-dispatcher": "2.1.*", - "symfony/http-kernel": "2.1.*", - "symfony/routing": "2.1.*", - "symfony/yaml": "2.1.*", + "symfony/config": "2.3.*", + "symfony/dependency-injection": "2.3.*", + "symfony/event-dispatcher": "2.3.*", + "symfony/http-kernel": "2.3.*", + "symfony/routing": "2.3.*", + "symfony/yaml": "2.3.*", "twig/twig": "1.13.*" }, "require-dev": { diff --git a/phpBB/composer.lock b/phpBB/composer.lock index 1ba6cb6f83..e04e169f4b 100644 --- a/phpBB/composer.lock +++ b/phpBB/composer.lock @@ -3,30 +3,74 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "6e6125b88160e28568edcb9fd007abed", + "hash": "fcad562b3b6768f0e355d93edc0db405", "packages": [ + { + "name": "psr/log", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-0": { + "Psr\\Log\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2012-12-21 11:40:51" + }, { "name": "symfony/config", - "version": "v2.1.11", + "version": "v2.3.4", "target-dir": "Symfony/Component/Config", "source": { "type": "git", "url": "https://github.com/symfony/Config.git", - "reference": "v2.1.11" + "reference": "65a927c15ca5a911ba2fa277a5457fa8129505b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Config/zipball/v2.1.11", - "reference": "v2.1.11", + "url": "https://api.github.com/repos/symfony/Config/zipball/65a927c15ca5a911ba2fa277a5457fa8129505b0", + "reference": "65a927c15ca5a911ba2fa277a5457fa8129505b0", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.3.3", + "symfony/filesystem": "~2.3" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, "autoload": { "psr-0": { - "Symfony\\Component\\Config": "" + "Symfony\\Component\\Config\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -45,38 +89,100 @@ ], "description": "Symfony Config Component", "homepage": "http://symfony.com", - "time": "2013-05-09 15:22:40" + "time": "2013-08-06 05:49:23" + }, + { + "name": "symfony/debug", + "version": "v2.3.4", + "target-dir": "Symfony/Component/Debug", + "source": { + "type": "git", + "url": "https://github.com/symfony/Debug.git", + "reference": "729f6d19cfc401c4942e43fcc1059103bd6df130" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Debug/zipball/729f6d19cfc401c4942e43fcc1059103bd6df130", + "reference": "729f6d19cfc401c4942e43fcc1059103bd6df130", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/http-foundation": "~2.1", + "symfony/http-kernel": "~2.1" + }, + "suggest": { + "symfony/class-loader": "", + "symfony/http-foundation": "", + "symfony/http-kernel": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Debug\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Debug Component", + "homepage": "http://symfony.com", + "time": "2013-08-08 14:16:10" }, { "name": "symfony/dependency-injection", - "version": "v2.1.11", + "version": "v2.3.4", "target-dir": "Symfony/Component/DependencyInjection", "source": { "type": "git", "url": "https://github.com/symfony/DependencyInjection.git", - "reference": "v2.1.11" + "reference": "3678aa969e5bfeb8515a1f3047c63e8104723f5c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/v2.1.11", - "reference": "v2.1.11", + "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/3678aa969e5bfeb8515a1f3047c63e8104723f5c", + "reference": "3678aa969e5bfeb8515a1f3047c63e8104723f5c", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "symfony/config": "2.1.*", - "symfony/yaml": "2.1.*" + "symfony/config": "~2.2", + "symfony/yaml": "~2.0" }, "suggest": { - "symfony/config": "2.1.*", - "symfony/yaml": "2.1.*" + "symfony/config": "", + "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", + "symfony/yaml": "" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, "autoload": { "psr-0": { - "Symfony\\Component\\DependencyInjection": "" + "Symfony\\Component\\DependencyInjection\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -95,37 +201,42 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "http://symfony.com", - "time": "2013-05-03 05:08:13" + "time": "2013-07-25 17:13:25" }, { "name": "symfony/event-dispatcher", - "version": "v2.1.11", + "version": "v2.3.4", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "v2.1.11" + "reference": "41c9826457c65fa3cf746f214985b7ca9cba42f8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/v2.1.11", - "reference": "v2.1.11", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/41c9826457c65fa3cf746f214985b7ca9cba42f8", + "reference": "41c9826457c65fa3cf746f214985b7ca9cba42f8", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "symfony/dependency-injection": "2.1.*" + "symfony/dependency-injection": "~2.0" }, "suggest": { - "symfony/dependency-injection": "2.1.*", - "symfony/http-kernel": "2.1.*" + "symfony/dependency-injection": "", + "symfony/http-kernel": "" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, "autoload": { "psr-0": { - "Symfony\\Component\\EventDispatcher": "" + "Symfony\\Component\\EventDispatcher\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -144,32 +255,86 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "http://symfony.com", - "time": "2013-02-11 11:26:14" + "time": "2013-07-21 12:12:18" + }, + { + "name": "symfony/filesystem", + "version": "v2.3.4", + "target-dir": "Symfony/Component/Filesystem", + "source": { + "type": "git", + "url": "https://github.com/symfony/Filesystem.git", + "reference": "87acbbef6d35ba649f96f09cc572c45119b360c3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/87acbbef6d35ba649f96f09cc572c45119b360c3", + "reference": "87acbbef6d35ba649f96f09cc572c45119b360c3", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Filesystem\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "http://symfony.com", + "time": "2013-07-21 12:12:18" }, { "name": "symfony/http-foundation", - "version": "v2.1.11", + "version": "v2.3.4", "target-dir": "Symfony/Component/HttpFoundation", "source": { "type": "git", "url": "https://github.com/symfony/HttpFoundation.git", - "reference": "v2.1.11" + "reference": "fdf130fe65457aedbc4639a22f4ef9d3be5c002c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/v2.1.11", - "reference": "v2.1.11", + "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/fdf130fe65457aedbc4639a22f4ef9d3be5c002c", + "reference": "fdf130fe65457aedbc4639a22f4ef9d3be5c002c", "shasum": "" }, "require": { "php": ">=5.3.3" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, "autoload": { "psr-0": { - "Symfony\\Component\\HttpFoundation": "", - "SessionHandlerInterface": "Symfony/Component/HttpFoundation/Resources/stubs" - } + "Symfony\\Component\\HttpFoundation\\": "" + }, + "classmap": [ + "Symfony/Component/HttpFoundation/Resources/stubs" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -187,50 +352,59 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "http://symfony.com", - "time": "2013-05-26 18:42:07" + "time": "2013-08-26 05:49:51" }, { "name": "symfony/http-kernel", - "version": "v2.1.11", + "version": "v2.3.4", "target-dir": "Symfony/Component/HttpKernel", "source": { "type": "git", "url": "https://github.com/symfony/HttpKernel.git", - "reference": "v2.1.11" + "reference": "9d35da40f07bbe7a4f8dfbc41555d2b69de674bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/v2.1.11", - "reference": "v2.1.11", + "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/9d35da40f07bbe7a4f8dfbc41555d2b69de674bf", + "reference": "9d35da40f07bbe7a4f8dfbc41555d2b69de674bf", "shasum": "" }, "require": { "php": ">=5.3.3", - "symfony/event-dispatcher": "2.1.*", - "symfony/http-foundation": "2.1.*" + "psr/log": "~1.0", + "symfony/debug": "~2.3", + "symfony/event-dispatcher": "~2.1", + "symfony/http-foundation": "~2.2" }, "require-dev": { - "symfony/browser-kit": "2.1.*", - "symfony/class-loader": "2.1.*", - "symfony/config": "2.1.*", - "symfony/console": "2.1.*", - "symfony/dependency-injection": "2.1.*", - "symfony/finder": "2.1.*", - "symfony/process": "2.1.*", - "symfony/routing": "2.1.*" + "symfony/browser-kit": "~2.2", + "symfony/class-loader": "~2.1", + "symfony/config": "~2.0", + "symfony/console": "~2.2", + "symfony/dependency-injection": "~2.0", + "symfony/finder": "~2.0", + "symfony/process": "~2.0", + "symfony/routing": "~2.2", + "symfony/stopwatch": "~2.2", + "symfony/templating": "~2.2" }, "suggest": { - "symfony/browser-kit": "2.1.*", - "symfony/class-loader": "2.1.*", - "symfony/config": "2.1.*", - "symfony/console": "2.1.*", - "symfony/dependency-injection": "2.1.*", - "symfony/finder": "2.1.*" + "symfony/browser-kit": "", + "symfony/class-loader": "", + "symfony/config": "", + "symfony/console": "", + "symfony/dependency-injection": "", + "symfony/finder": "" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, "autoload": { "psr-0": { - "Symfony\\Component\\HttpKernel": "" + "Symfony\\Component\\HttpKernel\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -249,41 +423,46 @@ ], "description": "Symfony HttpKernel Component", "homepage": "http://symfony.com", - "time": "2013-06-02 12:29:05" + "time": "2013-08-27 08:58:24" }, { "name": "symfony/routing", - "version": "v2.1.11", + "version": "v2.3.4", "target-dir": "Symfony/Component/Routing", "source": { "type": "git", "url": "https://github.com/symfony/Routing.git", - "reference": "v2.1.11" + "reference": "69af3f07dbf3ae93dd513dbc373f561cb2e7f143" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Routing/zipball/v2.1.11", - "reference": "v2.1.11", + "url": "https://api.github.com/repos/symfony/Routing/zipball/69af3f07dbf3ae93dd513dbc373f561cb2e7f143", + "reference": "69af3f07dbf3ae93dd513dbc373f561cb2e7f143", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "doctrine/common": ">=2.2,<3.0", - "symfony/config": "2.1.*", - "symfony/http-kernel": "2.1.*", - "symfony/yaml": "2.1.*" + "doctrine/common": "~2.2", + "psr/log": "~1.0", + "symfony/config": "~2.2", + "symfony/yaml": "~2.0" }, "suggest": { - "doctrine/common": "~2.2", - "symfony/config": "2.1.*", - "symfony/yaml": "2.1.*" + "doctrine/common": "", + "symfony/config": "", + "symfony/yaml": "" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, "autoload": { "psr-0": { - "Symfony\\Component\\Routing": "" + "Symfony\\Component\\Routing\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -302,30 +481,35 @@ ], "description": "Symfony Routing Component", "homepage": "http://symfony.com", - "time": "2013-05-06 10:48:41" + "time": "2013-08-23 15:14:07" }, { "name": "symfony/yaml", - "version": "v2.1.11", + "version": "v2.3.4", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "v2.1.11" + "reference": "5a279f1b5f5e1045a6c432354d9ea727ff3a9847" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/v2.1.11", - "reference": "v2.1.11", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/5a279f1b5f5e1045a6c432354d9ea727ff3a9847", + "reference": "5a279f1b5f5e1045a6c432354d9ea727ff3a9847", "shasum": "" }, "require": { "php": ">=5.3.3" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, "autoload": { "psr-0": { - "Symfony\\Component\\Yaml": "" + "Symfony\\Component\\Yaml\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -344,20 +528,20 @@ ], "description": "Symfony Yaml Component", "homepage": "http://symfony.com", - "time": "2013-05-10 00:09:46" + "time": "2013-08-24 15:26:22" }, { "name": "twig/twig", - "version": "v1.13.1", + "version": "v1.13.2", "source": { "type": "git", "url": "https://github.com/fabpot/Twig.git", - "reference": "v1.13.1" + "reference": "6d6a1009427d1f398c9d40904147bf9f723d5755" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fabpot/Twig/zipball/v1.13.1", - "reference": "v1.13.1", + "url": "https://api.github.com/repos/fabpot/Twig/zipball/6d6a1009427d1f398c9d40904147bf9f723d5755", + "reference": "6d6a1009427d1f398c9d40904147bf9f723d5755", "shasum": "" }, "require": { @@ -376,7 +560,7 @@ }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3" + "BSD-3-Clause" ], "authors": [ { @@ -393,7 +577,7 @@ "keywords": [ "templating" ], - "time": "2013-06-06 06:06:01" + "time": "2013-08-03 15:35:31" } ], "packages-dev": [ @@ -402,13 +586,13 @@ "version": "v0.1.0", "source": { "type": "git", - "url": "https://github.com/fabpot/Goutte", - "reference": "v0.1.0" + "url": "https://github.com/fabpot/Goutte.git", + "reference": "dcfba09b0f3781b2629693ab627bfa61ad4753bb" }, "dist": { "type": "zip", - "url": "https://github.com/fabpot/Goutte/archive/v0.1.0.zip", - "reference": "v0.1.0", + "url": "https://api.github.com/repos/fabpot/Goutte/zipball/dcfba09b0f3781b2629693ab627bfa61ad4753bb", + "reference": "dcfba09b0f3781b2629693ab627bfa61ad4753bb", "shasum": "" }, "require": { @@ -454,13 +638,13 @@ "version": "v3.0.7", "source": { "type": "git", - "url": "https://github.com/guzzle/guzzle", - "reference": "v3.0.7" + "url": "https://github.com/guzzle/guzzle.git", + "reference": "f31f35d1669382936861533bd0217fcf830dc9a9" }, "dist": { "type": "zip", - "url": "https://github.com/guzzle/guzzle/archive/v3.0.7.zip", - "reference": "v3.0.7", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/f31f35d1669382936861533bd0217fcf830dc9a9", + "reference": "f31f35d1669382936861533bd0217fcf830dc9a9", "shasum": "" }, "require": { @@ -546,13 +730,13 @@ "version": "2.4.14", "source": { "type": "git", - "url": "https://github.com/phingofficial/phing", - "reference": "2.4.14" + "url": "https://github.com/phingofficial/phing.git", + "reference": "41075d93ca254f1c90c79ec7ce81be2b2629e138" }, "dist": { "type": "zip", - "url": "https://github.com/phingofficial/phing/archive/2.4.14.zip", - "reference": "2.4.14", + "url": "https://api.github.com/repos/phingofficial/phing/zipball/41075d93ca254f1c90c79ec7ce81be2b2629e138", + "reference": "41075d93ca254f1c90c79ec7ce81be2b2629e138", "shasum": "" }, "require": { @@ -599,12 +783,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/dbunit.git", - "reference": "1.2.3" + "reference": "8386782a2d55153e44a06eb1a9d13d6ed35d9c2d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/dbunit/zipball/1.2.3", - "reference": "1.2.3", + "url": "https://api.github.com/repos/sebastianbergmann/dbunit/zipball/8386782a2d55153e44a06eb1a9d13d6ed35d9c2d", + "reference": "8386782a2d55153e44a06eb1a9d13d6ed35d9c2d", "shasum": "" }, "require": { @@ -657,12 +841,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "1.2.12" + "reference": "0e9958c459d675fb497d8dc5001c91d335734e48" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/1.2.12", - "reference": "1.2.12", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/0e9958c459d675fb497d8dc5001c91d335734e48", + "reference": "0e9958c459d675fb497d8dc5001c91d335734e48", "shasum": "" }, "require": { @@ -717,13 +901,13 @@ "version": "1.3.3", "source": { "type": "git", - "url": "git://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "1.3.3" + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "16a78140ed2fc01b945cfa539665fadc6a038029" }, "dist": { "type": "zip", - "url": "https://github.com/sebastianbergmann/php-file-iterator/zipball/1.3.3", - "reference": "1.3.3", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/16a78140ed2fc01b945cfa539665fadc6a038029", + "reference": "16a78140ed2fc01b945cfa539665fadc6a038029", "shasum": "" }, "require": { @@ -755,20 +939,20 @@ "filesystem", "iterator" ], - "time": "2012-10-11 04:44:38" + "time": "2012-10-11 11:44:38" }, { "name": "phpunit/php-text-template", "version": "1.1.4", "source": { "type": "git", - "url": "git://github.com/sebastianbergmann/php-text-template.git", - "reference": "1.1.4" + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "5180896f51c5b3648ac946b05f9ec02be78a0b23" }, "dist": { "type": "zip", - "url": "https://github.com/sebastianbergmann/php-text-template/zipball/1.1.4", - "reference": "1.1.4", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5180896f51c5b3648ac946b05f9ec02be78a0b23", + "reference": "5180896f51c5b3648ac946b05f9ec02be78a0b23", "shasum": "" }, "require": { @@ -799,20 +983,20 @@ "keywords": [ "template" ], - "time": "2012-10-31 11:15:28" + "time": "2012-10-31 18:15:28" }, { "name": "phpunit/php-timer", - "version": "1.0.4", + "version": "1.0.5", "source": { "type": "git", - "url": "git://github.com/sebastianbergmann/php-timer.git", - "reference": "1.0.4" + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" }, "dist": { "type": "zip", - "url": "https://github.com/sebastianbergmann/php-timer/zipball/1.0.4", - "reference": "1.0.4", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", "shasum": "" }, "require": { @@ -839,24 +1023,24 @@ } ], "description": "Utility class for timing", - "homepage": "http://www.phpunit.de/", + "homepage": "https://github.com/sebastianbergmann/php-timer/", "keywords": [ "timer" ], - "time": "2012-10-11 04:45:58" + "time": "2013-08-02 07:42:54" }, { "name": "phpunit/php-token-stream", - "version": "1.1.5", + "version": "1.2.0", "source": { "type": "git", - "url": "git://github.com/sebastianbergmann/php-token-stream.git", - "reference": "1.1.5" + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "31babf400e5b5868573bf49a000a3519d3978233" }, "dist": { "type": "zip", - "url": "https://github.com/sebastianbergmann/php-token-stream/zipball/1.1.5", - "reference": "1.1.5", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/31babf400e5b5868573bf49a000a3519d3978233", + "reference": "31babf400e5b5868573bf49a000a3519d3978233", "shasum": "" }, "require": { @@ -864,6 +1048,11 @@ "php": ">=5.3.3" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2-dev" + } + }, "autoload": { "classmap": [ "PHP/" @@ -884,24 +1073,24 @@ } ], "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "http://www.phpunit.de/", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", "keywords": [ "tokenizer" ], - "time": "2012-10-11 04:47:14" + "time": "2013-08-04 05:57:48" }, { "name": "phpunit/phpunit", - "version": "3.7.22", + "version": "3.7.24", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "3.7.22" + "reference": "af7b77ccb5c64458bdfca95665d29558d1df7d08" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3.7.22", - "reference": "3.7.22", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/af7b77ccb5c64458bdfca95665d29558d1df7d08", + "reference": "af7b77ccb5c64458bdfca95665d29558d1df7d08", "shasum": "" }, "require": { @@ -913,7 +1102,7 @@ "phpunit/php-code-coverage": "~1.2.1", "phpunit/php-file-iterator": ">=1.3.1", "phpunit/php-text-template": ">=1.1.1", - "phpunit/php-timer": "~1.0.2", + "phpunit/php-timer": ">=1.0.4", "phpunit/phpunit-mock-objects": "~1.2.0", "symfony/yaml": "~2.0" }, @@ -962,20 +1151,20 @@ "testing", "xunit" ], - "time": "2013-07-06 06:29:15" + "time": "2013-08-09 06:58:24" }, { "name": "phpunit/phpunit-mock-objects", "version": "1.2.3", "source": { "type": "git", - "url": "git://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "1.2.3" + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875" }, "dist": { "type": "zip", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects/archive/1.2.3.zip", - "reference": "1.2.3", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5794e3c5c5ba0fb037b11d8151add2a07fa82875", + "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875", "shasum": "" }, "require": { @@ -1015,17 +1204,17 @@ }, { "name": "symfony/browser-kit", - "version": "v2.1.11", + "version": "v2.1.12", "target-dir": "Symfony/Component/BrowserKit", "source": { "type": "git", "url": "https://github.com/symfony/BrowserKit.git", - "reference": "v2.1.11" + "reference": "0bb8f07107a2911db0fe49c39f96b5018e5ab678" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/BrowserKit/zipball/v2.1.11", - "reference": "v2.1.11", + "url": "https://api.github.com/repos/symfony/BrowserKit/zipball/0bb8f07107a2911db0fe49c39f96b5018e5ab678", + "reference": "0bb8f07107a2911db0fe49c39f96b5018e5ab678", "shasum": "" }, "require": { @@ -1065,17 +1254,17 @@ }, { "name": "symfony/css-selector", - "version": "v2.1.11", + "version": "v2.1.12", "target-dir": "Symfony/Component/CssSelector", "source": { "type": "git", "url": "https://github.com/symfony/CssSelector.git", - "reference": "v2.1.11" + "reference": "bf7bb82a099dfb26b018daf70ad1985fea4d2997" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/CssSelector/zipball/v2.1.11", - "reference": "v2.1.11", + "url": "https://api.github.com/repos/symfony/CssSelector/zipball/bf7bb82a099dfb26b018daf70ad1985fea4d2997", + "reference": "bf7bb82a099dfb26b018daf70ad1985fea4d2997", "shasum": "" }, "require": { @@ -1107,17 +1296,17 @@ }, { "name": "symfony/dom-crawler", - "version": "v2.1.11", + "version": "v2.1.12", "target-dir": "Symfony/Component/DomCrawler", "source": { "type": "git", "url": "https://github.com/symfony/DomCrawler.git", - "reference": "v2.1.11" + "reference": "bedfd7eb44e3b1224d1e18335d2e36bbbed26cbe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/DomCrawler/zipball/v2.1.11", - "reference": "v2.1.11", + "url": "https://api.github.com/repos/symfony/DomCrawler/zipball/bedfd7eb44e3b1224d1e18335d2e36bbbed26cbe", + "reference": "bedfd7eb44e3b1224d1e18335d2e36bbbed26cbe", "shasum": "" }, "require": { @@ -1155,17 +1344,17 @@ }, { "name": "symfony/finder", - "version": "v2.1.11", + "version": "v2.1.12", "target-dir": "Symfony/Component/Finder", "source": { "type": "git", "url": "https://github.com/symfony/Finder.git", - "reference": "v2.1.11" + "reference": "0dbc61194b58bc513e003789853ddfe0aea8cf33" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Finder/zipball/v2.1.11", - "reference": "v2.1.11", + "url": "https://api.github.com/repos/symfony/Finder/zipball/0dbc61194b58bc513e003789853ddfe0aea8cf33", + "reference": "0dbc61194b58bc513e003789853ddfe0aea8cf33", "shasum": "" }, "require": { @@ -1197,17 +1386,17 @@ }, { "name": "symfony/process", - "version": "v2.1.11", + "version": "v2.1.12", "target-dir": "Symfony/Component/Process", "source": { "type": "git", "url": "https://github.com/symfony/Process.git", - "reference": "v2.1.11" + "reference": "be3cac4d0575bc547a0f2e85ceb4f19a5a8b3025" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Process/zipball/v2.1.11", - "reference": "v2.1.11", + "url": "https://api.github.com/repos/symfony/Process/zipball/be3cac4d0575bc547a0f2e85ceb4f19a5a8b3025", + "reference": "be3cac4d0575bc547a0f2e85ceb4f19a5a8b3025", "shasum": "" }, "require": { -- cgit v1.2.1 From c8d5ec892745f9bfc784cd8f7f632fee4a371ff7 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 2 Sep 2013 16:35:42 -0500 Subject: [ticket/11812] Fix empty define PHPBB3-11812 --- phpBB/phpbb/template/twig/lexer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index a33de70d69..7ab569313c 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -130,7 +130,7 @@ class phpbb_template_twig_lexer extends Twig_Lexer // E.g. 'asdf'"' -> asdf'" // E.g. "asdf'"" -> asdf'" // E.g. 'asdf'" -> 'asdf'" - $matches[2] = preg_replace('#^([\'"])?(.+?)\1$#', '$2', $matches[2]); + $matches[2] = preg_replace('#^([\'"])?(.*?)\1$#', '$2', $matches[2]); // Replace template variables with start/end to parse variables (' ~ TEST ~ '.html) $matches[2] = preg_replace('#{([a-zA-Z0-9_\.$]+)}#', "'~ \$1 ~'", $matches[2]); -- cgit v1.2.1 From ed0d7e9ea07c565c3e46459f1a47bc49e3f9b14a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 2 Sep 2013 23:38:42 +0200 Subject: [prep-release-3.0.12] Bumping version number for 3.0.12-RC3. --- phpBB/includes/constants.php | 2 +- phpBB/install/database_update.php | 8 +++++++- phpBB/install/schemas/schema_data.sql | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index 09e1e50b8d..c57b90a5dd 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -25,7 +25,7 @@ if (!defined('IN_PHPBB')) */ // phpBB Version -define('PHPBB_VERSION', '3.0.12-RC2'); +define('PHPBB_VERSION', '3.0.12-RC3'); // QA-related // define('PHPBB_QA', 1); diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 59f795e37e..01bfb7b251 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -define('UPDATES_TO_VERSION', '3.0.12-RC2'); +define('UPDATES_TO_VERSION', '3.0.12-RC3'); // Enter any version to update from to test updates. The version within the db will not be updated. define('DEBUG_FROM_VERSION', false); @@ -1007,6 +1007,8 @@ function database_update_info() '3.0.11' => array(), // No changes from 3.0.12-RC1 to 3.0.12-RC2 '3.0.12-RC1' => array(), + // No changes from 3.0.12-RC2 to 3.0.12-RC3 + '3.0.12-RC2' => array(), /** @todo DROP LOGIN_ATTEMPT_TABLE.attempt_id in 3.0.13-RC1 */ ); @@ -2242,6 +2244,10 @@ function change_database_data(&$no_updates, $version) // No changes from 3.0.12-RC1 to 3.0.12-RC2 case '3.0.12-RC1': break; + + // No changes from 3.0.12-RC2 to 3.0.12-RC3 + case '3.0.12-RC2': + break; } } diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index cfe3c0c4cb..3f54d4f24f 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -246,7 +246,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('topics_per_page', INSERT INTO phpbb_config (config_name, config_value) VALUES ('tpl_allow_php', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('upload_icons_path', 'images/upload_icons'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('upload_path', 'files'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('version', '3.0.12-RC2'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('version', '3.0.12-RC3'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('warnings_expire_days', '90'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('warnings_gc', '14400'); -- cgit v1.2.1 From 50818a342bf60eba038b47af36f7ff32d3f7867a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 2 Sep 2013 23:42:45 +0200 Subject: [prep-release-3.0.12] Update Changelog for 3.0.12-RC3 release. --- phpBB/docs/CHANGELOG.html | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB') diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html index f2d5ddc212..26f1d6ff94 100644 --- a/phpBB/docs/CHANGELOG.html +++ b/phpBB/docs/CHANGELOG.html @@ -192,6 +192,9 @@
  • [PHPBB3-11674] - Do not include vendor folder if there are no dependencies.
  • [PHPBB3-11524] - MySQL Upgrader throws warnings on PHP 5.4
  • [PHPBB3-11720] - Reporting posts leads to white page error
  • +
  • [PHPBB3-11769] - Wrong poster in subscription email when poster is using the Quote button
  • +
  • [PHPBB3-11775] - Error while moving posts to a new topic
  • +
  • [PHPBB3-11802] - Undefined variable $browser in /download/file.php
  • Improvement

      -- cgit v1.2.1 From 536eeb7afaee59020fa46a5934943482aae440eb Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 2 Sep 2013 16:58:34 -0500 Subject: [ticket/11755] MySQL upgrader out of date De-duplicating code from create_schema_files, mysql_upgrader. New file phpbb/db/schema_data which contains all the current schema data. New function in db_tools public static function get_dbms_type_map() to make the type map available everywhere (without requiring $db be setup already) PHPBB3-11755 --- phpBB/develop/create_schema_files.php | 1403 +-------------------------------- phpBB/develop/mysql_upgrader.php | 1151 +-------------------------- phpBB/phpbb/db/schema_data.php | 1194 ++++++++++++++++++++++++++++ phpBB/phpbb/db/tools.php | 494 ++++++------ 4 files changed, 1456 insertions(+), 2786 deletions(-) create mode 100644 phpBB/phpbb/db/schema_data.php (limited to 'phpBB') diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 316fbe19e6..3aacd31e70 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -18,218 +18,12 @@ if (!is_writable($schema_path)) die('Schema path not writable'); } -$schema_data = get_schema_struct(); -$dbms_type_map = array( - 'mysql_41' => array( - 'INT:' => 'int(%d)', - 'BINT' => 'bigint(20)', - 'UINT' => 'mediumint(8) UNSIGNED', - 'UINT:' => 'int(%d) UNSIGNED', - 'TINT:' => 'tinyint(%d)', - 'USINT' => 'smallint(4) UNSIGNED', - 'BOOL' => 'tinyint(1) UNSIGNED', - 'VCHAR' => 'varchar(255)', - 'VCHAR:' => 'varchar(%d)', - 'CHAR:' => 'char(%d)', - 'XSTEXT' => 'text', - 'XSTEXT_UNI'=> 'varchar(100)', - 'STEXT' => 'text', - 'STEXT_UNI' => 'varchar(255)', - 'TEXT' => 'text', - 'TEXT_UNI' => 'text', - 'MTEXT' => 'mediumtext', - 'MTEXT_UNI' => 'mediumtext', - 'TIMESTAMP' => 'int(11) UNSIGNED', - 'DECIMAL' => 'decimal(5,2)', - 'DECIMAL:' => 'decimal(%d,2)', - 'PDECIMAL' => 'decimal(6,3)', - 'PDECIMAL:' => 'decimal(%d,3)', - 'VCHAR_UNI' => 'varchar(255)', - 'VCHAR_UNI:'=> 'varchar(%d)', - 'VCHAR_CI' => 'varchar(255)', - 'VARBINARY' => 'varbinary(255)', - ), - - 'mysql_40' => array( - 'INT:' => 'int(%d)', - 'BINT' => 'bigint(20)', - 'UINT' => 'mediumint(8) UNSIGNED', - 'UINT:' => 'int(%d) UNSIGNED', - 'TINT:' => 'tinyint(%d)', - 'USINT' => 'smallint(4) UNSIGNED', - 'BOOL' => 'tinyint(1) UNSIGNED', - 'VCHAR' => 'varbinary(255)', - 'VCHAR:' => 'varbinary(%d)', - 'CHAR:' => 'binary(%d)', - 'XSTEXT' => 'blob', - 'XSTEXT_UNI'=> 'blob', - 'STEXT' => 'blob', - 'STEXT_UNI' => 'blob', - 'TEXT' => 'blob', - 'TEXT_UNI' => 'blob', - 'MTEXT' => 'mediumblob', - 'MTEXT_UNI' => 'mediumblob', - 'TIMESTAMP' => 'int(11) UNSIGNED', - 'DECIMAL' => 'decimal(5,2)', - 'DECIMAL:' => 'decimal(%d,2)', - 'PDECIMAL' => 'decimal(6,3)', - 'PDECIMAL:' => 'decimal(%d,3)', - 'VCHAR_UNI' => 'blob', - 'VCHAR_UNI:'=> array('varbinary(%d)', 'limit' => array('mult', 3, 255, 'blob')), - 'VCHAR_CI' => 'blob', - 'VARBINARY' => 'varbinary(255)', - ), - - 'firebird' => array( - 'INT:' => 'INTEGER', - 'BINT' => 'DOUBLE PRECISION', - 'UINT' => 'INTEGER', - 'UINT:' => 'INTEGER', - 'TINT:' => 'INTEGER', - 'USINT' => 'INTEGER', - 'BOOL' => 'INTEGER', - 'VCHAR' => 'VARCHAR(255) CHARACTER SET NONE', - 'VCHAR:' => 'VARCHAR(%d) CHARACTER SET NONE', - 'CHAR:' => 'CHAR(%d) CHARACTER SET NONE', - 'XSTEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', - 'STEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', - 'TEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', - 'MTEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', - 'XSTEXT_UNI'=> 'VARCHAR(100) CHARACTER SET UTF8', - 'STEXT_UNI' => 'VARCHAR(255) CHARACTER SET UTF8', - 'TEXT_UNI' => 'BLOB SUB_TYPE TEXT CHARACTER SET UTF8', - 'MTEXT_UNI' => 'BLOB SUB_TYPE TEXT CHARACTER SET UTF8', - 'TIMESTAMP' => 'INTEGER', - 'DECIMAL' => 'DOUBLE PRECISION', - 'DECIMAL:' => 'DOUBLE PRECISION', - 'PDECIMAL' => 'DOUBLE PRECISION', - 'PDECIMAL:' => 'DOUBLE PRECISION', - 'VCHAR_UNI' => 'VARCHAR(255) CHARACTER SET UTF8', - 'VCHAR_UNI:'=> 'VARCHAR(%d) CHARACTER SET UTF8', - 'VCHAR_CI' => 'VARCHAR(255) CHARACTER SET UTF8', - 'VARBINARY' => 'CHAR(255) CHARACTER SET NONE', - ), - - 'mssql' => array( - 'INT:' => '[int]', - 'BINT' => '[float]', - 'UINT' => '[int]', - 'UINT:' => '[int]', - 'TINT:' => '[int]', - 'USINT' => '[int]', - 'BOOL' => '[int]', - 'VCHAR' => '[varchar] (255)', - 'VCHAR:' => '[varchar] (%d)', - 'CHAR:' => '[char] (%d)', - 'XSTEXT' => '[varchar] (1000)', - 'STEXT' => '[varchar] (3000)', - 'TEXT' => '[varchar] (8000)', - 'MTEXT' => '[text]', - 'XSTEXT_UNI'=> '[varchar] (100)', - 'STEXT_UNI' => '[varchar] (255)', - 'TEXT_UNI' => '[varchar] (4000)', - 'MTEXT_UNI' => '[text]', - 'TIMESTAMP' => '[int]', - 'DECIMAL' => '[float]', - 'DECIMAL:' => '[float]', - 'PDECIMAL' => '[float]', - 'PDECIMAL:' => '[float]', - 'VCHAR_UNI' => '[varchar] (255)', - 'VCHAR_UNI:'=> '[varchar] (%d)', - 'VCHAR_CI' => '[varchar] (255)', - 'VARBINARY' => '[varchar] (255)', - ), - - 'oracle' => array( - 'INT:' => 'number(%d)', - 'BINT' => 'number(20)', - 'UINT' => 'number(8)', - 'UINT:' => 'number(%d)', - 'TINT:' => 'number(%d)', - 'USINT' => 'number(4)', - 'BOOL' => 'number(1)', - 'VCHAR' => 'varchar2(255)', - 'VCHAR:' => 'varchar2(%d)', - 'CHAR:' => 'char(%d)', - 'XSTEXT' => 'varchar2(1000)', - 'STEXT' => 'varchar2(3000)', - 'TEXT' => 'clob', - 'MTEXT' => 'clob', - 'XSTEXT_UNI'=> 'varchar2(300)', - 'STEXT_UNI' => 'varchar2(765)', - 'TEXT_UNI' => 'clob', - 'MTEXT_UNI' => 'clob', - 'TIMESTAMP' => 'number(11)', - 'DECIMAL' => 'number(5, 2)', - 'DECIMAL:' => 'number(%d, 2)', - 'PDECIMAL' => 'number(6, 3)', - 'PDECIMAL:' => 'number(%d, 3)', - 'VCHAR_UNI' => 'varchar2(765)', - 'VCHAR_UNI:'=> array('varchar2(%d)', 'limit' => array('mult', 3, 765, 'clob')), - 'VCHAR_CI' => 'varchar2(255)', - 'VARBINARY' => 'raw(255)', - ), - - 'sqlite' => array( - 'INT:' => 'int(%d)', - 'BINT' => 'bigint(20)', - 'UINT' => 'INTEGER UNSIGNED', //'mediumint(8) UNSIGNED', - 'UINT:' => 'INTEGER UNSIGNED', // 'int(%d) UNSIGNED', - 'TINT:' => 'tinyint(%d)', - 'USINT' => 'INTEGER UNSIGNED', //'mediumint(4) UNSIGNED', - 'BOOL' => 'INTEGER UNSIGNED', //'tinyint(1) UNSIGNED', - 'VCHAR' => 'varchar(255)', - 'VCHAR:' => 'varchar(%d)', - 'CHAR:' => 'char(%d)', - 'XSTEXT' => 'text(65535)', - 'STEXT' => 'text(65535)', - 'TEXT' => 'text(65535)', - 'MTEXT' => 'mediumtext(16777215)', - 'XSTEXT_UNI'=> 'text(65535)', - 'STEXT_UNI' => 'text(65535)', - 'TEXT_UNI' => 'text(65535)', - 'MTEXT_UNI' => 'mediumtext(16777215)', - 'TIMESTAMP' => 'INTEGER UNSIGNED', //'int(11) UNSIGNED', - 'DECIMAL' => 'decimal(5,2)', - 'DECIMAL:' => 'decimal(%d,2)', - 'PDECIMAL' => 'decimal(6,3)', - 'PDECIMAL:' => 'decimal(%d,3)', - 'VCHAR_UNI' => 'varchar(255)', - 'VCHAR_UNI:'=> 'varchar(%d)', - 'VCHAR_CI' => 'varchar(255)', - 'VARBINARY' => 'blob', - ), - - 'postgres' => array( - 'INT:' => 'INT4', - 'BINT' => 'INT8', - 'UINT' => 'INT4', // unsigned - 'UINT:' => 'INT4', // unsigned - 'USINT' => 'INT2', // unsigned - 'BOOL' => 'INT2', // unsigned - 'TINT:' => 'INT2', - 'VCHAR' => 'varchar(255)', - 'VCHAR:' => 'varchar(%d)', - 'CHAR:' => 'char(%d)', - 'XSTEXT' => 'varchar(1000)', - 'STEXT' => 'varchar(3000)', - 'TEXT' => 'varchar(8000)', - 'MTEXT' => 'TEXT', - 'XSTEXT_UNI'=> 'varchar(100)', - 'STEXT_UNI' => 'varchar(255)', - 'TEXT_UNI' => 'varchar(4000)', - 'MTEXT_UNI' => 'TEXT', - 'TIMESTAMP' => 'INT4', // unsigned - 'DECIMAL' => 'decimal(5,2)', - 'DECIMAL:' => 'decimal(%d,2)', - 'PDECIMAL' => 'decimal(6,3)', - 'PDECIMAL:' => 'decimal(%d,3)', - 'VCHAR_UNI' => 'varchar(255)', - 'VCHAR_UNI:'=> 'varchar(%d)', - 'VCHAR_CI' => 'varchar_ci', - 'VARBINARY' => 'bytea', - ), -); +define('IN_PHPBB', true); + +require(dirname(__FILE__) . '/../phpbb/db/schema_data.php'); +require(dirname(__FILE__) . '/../phpbb/db/tools.php'); + +$dbms_type_map = phpbb_db_tools::get_dbms_type_map(); // A list of types being unsigned for better reference in some db's $unsigned_types = array('UINT', 'UINT:', 'USINT', 'BOOL', 'TIMESTAMP'); @@ -787,1191 +581,6 @@ foreach ($supported_dbms as $dbms) fclose($fp); } - -/** -* Define the basic structure -* The format: -* array('{TABLE_NAME}' => {TABLE_DATA}) -* {TABLE_DATA}: -* COLUMNS = array({column_name} = array({column_type}, {default}, {auto_increment})) -* PRIMARY_KEY = {column_name(s)} -* KEYS = array({key_name} = array({key_type}, {column_name(s)})), -* -* Column Types: -* INT:x => SIGNED int(x) -* BINT => BIGINT -* UINT => mediumint(8) UNSIGNED -* UINT:x => int(x) UNSIGNED -* TINT:x => tinyint(x) -* USINT => smallint(4) UNSIGNED (for _order columns) -* BOOL => tinyint(1) UNSIGNED -* VCHAR => varchar(255) -* CHAR:x => char(x) -* XSTEXT_UNI => text for storing 100 characters (topic_title for example) -* STEXT_UNI => text for storing 255 characters (normal input field with a max of 255 single-byte chars) - same as VCHAR_UNI -* TEXT_UNI => text for storing 3000 characters (short text, descriptions, comments, etc.) -* MTEXT_UNI => mediumtext (post text, large text) -* VCHAR:x => varchar(x) -* TIMESTAMP => int(11) UNSIGNED -* DECIMAL => decimal number (5,2) -* DECIMAL: => decimal number (x,2) -* PDECIMAL => precision decimal number (6,3) -* PDECIMAL: => precision decimal number (x,3) -* VCHAR_UNI => varchar(255) BINARY -* VCHAR_CI => varchar_ci for postgresql, others VCHAR -*/ -function get_schema_struct() -{ - $schema_data = array(); - - $schema_data['phpbb_attachments'] = array( - 'COLUMNS' => array( - 'attach_id' => array('UINT', NULL, 'auto_increment'), - 'post_msg_id' => array('UINT', 0), - 'topic_id' => array('UINT', 0), - 'in_message' => array('BOOL', 0), - 'poster_id' => array('UINT', 0), - 'is_orphan' => array('BOOL', 1), - 'physical_filename' => array('VCHAR', ''), - 'real_filename' => array('VCHAR', ''), - 'download_count' => array('UINT', 0), - 'attach_comment' => array('TEXT_UNI', ''), - 'extension' => array('VCHAR:100', ''), - 'mimetype' => array('VCHAR:100', ''), - 'filesize' => array('UINT:20', 0), - 'filetime' => array('TIMESTAMP', 0), - 'thumbnail' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => 'attach_id', - 'KEYS' => array( - 'filetime' => array('INDEX', 'filetime'), - 'post_msg_id' => array('INDEX', 'post_msg_id'), - 'topic_id' => array('INDEX', 'topic_id'), - 'poster_id' => array('INDEX', 'poster_id'), - 'is_orphan' => array('INDEX', 'is_orphan'), - ), - ); - - $schema_data['phpbb_acl_groups'] = array( - 'COLUMNS' => array( - 'group_id' => array('UINT', 0), - 'forum_id' => array('UINT', 0), - 'auth_option_id' => array('UINT', 0), - 'auth_role_id' => array('UINT', 0), - 'auth_setting' => array('TINT:2', 0), - ), - 'KEYS' => array( - 'group_id' => array('INDEX', 'group_id'), - 'auth_opt_id' => array('INDEX', 'auth_option_id'), - 'auth_role_id' => array('INDEX', 'auth_role_id'), - ), - ); - - $schema_data['phpbb_acl_options'] = array( - 'COLUMNS' => array( - 'auth_option_id' => array('UINT', NULL, 'auto_increment'), - 'auth_option' => array('VCHAR:50', ''), - 'is_global' => array('BOOL', 0), - 'is_local' => array('BOOL', 0), - 'founder_only' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => 'auth_option_id', - 'KEYS' => array( - 'auth_option' => array('UNIQUE', 'auth_option'), - ), - ); - - $schema_data['phpbb_acl_roles'] = array( - 'COLUMNS' => array( - 'role_id' => array('UINT', NULL, 'auto_increment'), - 'role_name' => array('VCHAR_UNI', ''), - 'role_description' => array('TEXT_UNI', ''), - 'role_type' => array('VCHAR:10', ''), - 'role_order' => array('USINT', 0), - ), - 'PRIMARY_KEY' => 'role_id', - 'KEYS' => array( - 'role_type' => array('INDEX', 'role_type'), - 'role_order' => array('INDEX', 'role_order'), - ), - ); - - $schema_data['phpbb_acl_roles_data'] = array( - 'COLUMNS' => array( - 'role_id' => array('UINT', 0), - 'auth_option_id' => array('UINT', 0), - 'auth_setting' => array('TINT:2', 0), - ), - 'PRIMARY_KEY' => array('role_id', 'auth_option_id'), - 'KEYS' => array( - 'ath_op_id' => array('INDEX', 'auth_option_id'), - ), - ); - - $schema_data['phpbb_acl_users'] = array( - 'COLUMNS' => array( - 'user_id' => array('UINT', 0), - 'forum_id' => array('UINT', 0), - 'auth_option_id' => array('UINT', 0), - 'auth_role_id' => array('UINT', 0), - 'auth_setting' => array('TINT:2', 0), - ), - 'KEYS' => array( - 'user_id' => array('INDEX', 'user_id'), - 'auth_option_id' => array('INDEX', 'auth_option_id'), - 'auth_role_id' => array('INDEX', 'auth_role_id'), - ), - ); - - $schema_data['phpbb_banlist'] = array( - 'COLUMNS' => array( - 'ban_id' => array('UINT', NULL, 'auto_increment'), - 'ban_userid' => array('UINT', 0), - 'ban_ip' => array('VCHAR:40', ''), - 'ban_email' => array('VCHAR_UNI:100', ''), - 'ban_start' => array('TIMESTAMP', 0), - 'ban_end' => array('TIMESTAMP', 0), - 'ban_exclude' => array('BOOL', 0), - 'ban_reason' => array('VCHAR_UNI', ''), - 'ban_give_reason' => array('VCHAR_UNI', ''), - ), - 'PRIMARY_KEY' => 'ban_id', - 'KEYS' => array( - 'ban_end' => array('INDEX', 'ban_end'), - 'ban_user' => array('INDEX', array('ban_userid', 'ban_exclude')), - 'ban_email' => array('INDEX', array('ban_email', 'ban_exclude')), - 'ban_ip' => array('INDEX', array('ban_ip', 'ban_exclude')), - ), - ); - - $schema_data['phpbb_bbcodes'] = array( - 'COLUMNS' => array( - 'bbcode_id' => array('USINT', 0), - 'bbcode_tag' => array('VCHAR:16', ''), - 'bbcode_helpline' => array('VCHAR_UNI', ''), - 'display_on_posting' => array('BOOL', 0), - 'bbcode_match' => array('TEXT_UNI', ''), - 'bbcode_tpl' => array('MTEXT_UNI', ''), - 'first_pass_match' => array('MTEXT_UNI', ''), - 'first_pass_replace' => array('MTEXT_UNI', ''), - 'second_pass_match' => array('MTEXT_UNI', ''), - 'second_pass_replace' => array('MTEXT_UNI', ''), - ), - 'PRIMARY_KEY' => 'bbcode_id', - 'KEYS' => array( - 'display_on_post' => array('INDEX', 'display_on_posting'), - ), - ); - - $schema_data['phpbb_bookmarks'] = array( - 'COLUMNS' => array( - 'topic_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - ), - 'PRIMARY_KEY' => array('topic_id', 'user_id'), - ); - - $schema_data['phpbb_bots'] = array( - 'COLUMNS' => array( - 'bot_id' => array('UINT', NULL, 'auto_increment'), - 'bot_active' => array('BOOL', 1), - 'bot_name' => array('STEXT_UNI', ''), - 'user_id' => array('UINT', 0), - 'bot_agent' => array('VCHAR', ''), - 'bot_ip' => array('VCHAR', ''), - ), - 'PRIMARY_KEY' => 'bot_id', - 'KEYS' => array( - 'bot_active' => array('INDEX', 'bot_active'), - ), - ); - - $schema_data['phpbb_config'] = array( - 'COLUMNS' => array( - 'config_name' => array('VCHAR', ''), - 'config_value' => array('VCHAR_UNI', ''), - 'is_dynamic' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => 'config_name', - 'KEYS' => array( - 'is_dynamic' => array('INDEX', 'is_dynamic'), - ), - ); - - $schema_data['phpbb_config_text'] = array( - 'COLUMNS' => array( - 'config_name' => array('VCHAR', ''), - 'config_value' => array('MTEXT', ''), - ), - 'PRIMARY_KEY' => 'config_name', - ); - - $schema_data['phpbb_confirm'] = array( - 'COLUMNS' => array( - 'confirm_id' => array('CHAR:32', ''), - 'session_id' => array('CHAR:32', ''), - 'confirm_type' => array('TINT:3', 0), - 'code' => array('VCHAR:8', ''), - 'seed' => array('UINT:10', 0), - 'attempts' => array('UINT', 0), - ), - 'PRIMARY_KEY' => array('session_id', 'confirm_id'), - 'KEYS' => array( - 'confirm_type' => array('INDEX', 'confirm_type'), - ), - ); - - $schema_data['phpbb_disallow'] = array( - 'COLUMNS' => array( - 'disallow_id' => array('UINT', NULL, 'auto_increment'), - 'disallow_username' => array('VCHAR_UNI:255', ''), - ), - 'PRIMARY_KEY' => 'disallow_id', - ); - - $schema_data['phpbb_drafts'] = array( - 'COLUMNS' => array( - 'draft_id' => array('UINT', NULL, 'auto_increment'), - 'user_id' => array('UINT', 0), - 'topic_id' => array('UINT', 0), - 'forum_id' => array('UINT', 0), - 'save_time' => array('TIMESTAMP', 0), - 'draft_subject' => array('STEXT_UNI', ''), - 'draft_message' => array('MTEXT_UNI', ''), - ), - 'PRIMARY_KEY' => 'draft_id', - 'KEYS' => array( - 'save_time' => array('INDEX', 'save_time'), - ), - ); - - $schema_data['phpbb_ext'] = array( - 'COLUMNS' => array( - 'ext_name' => array('VCHAR', ''), - 'ext_active' => array('BOOL', 0), - 'ext_state' => array('TEXT', ''), - ), - 'KEYS' => array( - 'ext_name' => array('UNIQUE', 'ext_name'), - ), - ); - - $schema_data['phpbb_extensions'] = array( - 'COLUMNS' => array( - 'extension_id' => array('UINT', NULL, 'auto_increment'), - 'group_id' => array('UINT', 0), - 'extension' => array('VCHAR:100', ''), - ), - 'PRIMARY_KEY' => 'extension_id', - ); - - $schema_data['phpbb_extension_groups'] = array( - 'COLUMNS' => array( - 'group_id' => array('UINT', NULL, 'auto_increment'), - 'group_name' => array('VCHAR_UNI', ''), - 'cat_id' => array('TINT:2', 0), - 'allow_group' => array('BOOL', 0), - 'download_mode' => array('BOOL', 1), - 'upload_icon' => array('VCHAR', ''), - 'max_filesize' => array('UINT:20', 0), - 'allowed_forums' => array('TEXT', ''), - 'allow_in_pm' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => 'group_id', - ); - - $schema_data['phpbb_forums'] = array( - 'COLUMNS' => array( - 'forum_id' => array('UINT', NULL, 'auto_increment'), - 'parent_id' => array('UINT', 0), - 'left_id' => array('UINT', 0), - 'right_id' => array('UINT', 0), - 'forum_parents' => array('MTEXT', ''), - 'forum_name' => array('STEXT_UNI', ''), - 'forum_desc' => array('TEXT_UNI', ''), - 'forum_desc_bitfield' => array('VCHAR:255', ''), - 'forum_desc_options' => array('UINT:11', 7), - 'forum_desc_uid' => array('VCHAR:8', ''), - 'forum_link' => array('VCHAR_UNI', ''), - 'forum_password' => array('VCHAR_UNI:40', ''), - 'forum_style' => array('UINT', 0), - 'forum_image' => array('VCHAR', ''), - 'forum_rules' => array('TEXT_UNI', ''), - 'forum_rules_link' => array('VCHAR_UNI', ''), - 'forum_rules_bitfield' => array('VCHAR:255', ''), - 'forum_rules_options' => array('UINT:11', 7), - 'forum_rules_uid' => array('VCHAR:8', ''), - 'forum_topics_per_page' => array('TINT:4', 0), - 'forum_type' => array('TINT:4', 0), - 'forum_status' => array('TINT:4', 0), - 'forum_posts_approved' => array('UINT', 0), - 'forum_posts_unapproved' => array('UINT', 0), - 'forum_posts_softdeleted' => array('UINT', 0), - 'forum_topics_approved' => array('UINT', 0), - 'forum_topics_unapproved' => array('UINT', 0), - 'forum_topics_softdeleted' => array('UINT', 0), - 'forum_last_post_id' => array('UINT', 0), - 'forum_last_poster_id' => array('UINT', 0), - 'forum_last_post_subject' => array('STEXT_UNI', ''), - 'forum_last_post_time' => array('TIMESTAMP', 0), - 'forum_last_poster_name'=> array('VCHAR_UNI', ''), - 'forum_last_poster_colour'=> array('VCHAR:6', ''), - 'forum_flags' => array('TINT:4', 32), - 'forum_options' => array('UINT:20', 0), - 'display_subforum_list' => array('BOOL', 1), - 'display_on_index' => array('BOOL', 1), - 'enable_indexing' => array('BOOL', 1), - 'enable_icons' => array('BOOL', 1), - 'enable_prune' => array('BOOL', 0), - 'prune_next' => array('TIMESTAMP', 0), - 'prune_days' => array('UINT', 0), - 'prune_viewed' => array('UINT', 0), - 'prune_freq' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'forum_id', - 'KEYS' => array( - 'left_right_id' => array('INDEX', array('left_id', 'right_id')), - 'forum_lastpost_id' => array('INDEX', 'forum_last_post_id'), - ), - ); - - $schema_data['phpbb_forums_access'] = array( - 'COLUMNS' => array( - 'forum_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'session_id' => array('CHAR:32', ''), - ), - 'PRIMARY_KEY' => array('forum_id', 'user_id', 'session_id'), - ); - - $schema_data['phpbb_forums_track'] = array( - 'COLUMNS' => array( - 'user_id' => array('UINT', 0), - 'forum_id' => array('UINT', 0), - 'mark_time' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => array('user_id', 'forum_id'), - ); - - $schema_data['phpbb_forums_watch'] = array( - 'COLUMNS' => array( - 'forum_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'notify_status' => array('BOOL', 0), - ), - 'KEYS' => array( - 'forum_id' => array('INDEX', 'forum_id'), - 'user_id' => array('INDEX', 'user_id'), - 'notify_stat' => array('INDEX', 'notify_status'), - ), - ); - - $schema_data['phpbb_groups'] = array( - 'COLUMNS' => array( - 'group_id' => array('UINT', NULL, 'auto_increment'), - 'group_type' => array('TINT:4', 1), - 'group_founder_manage' => array('BOOL', 0), - 'group_skip_auth' => array('BOOL', 0), - 'group_name' => array('VCHAR_CI', ''), - 'group_desc' => array('TEXT_UNI', ''), - 'group_desc_bitfield' => array('VCHAR:255', ''), - 'group_desc_options' => array('UINT:11', 7), - 'group_desc_uid' => array('VCHAR:8', ''), - 'group_display' => array('BOOL', 0), - 'group_avatar' => array('VCHAR', ''), - 'group_avatar_type' => array('VCHAR:255', ''), - 'group_avatar_width' => array('USINT', 0), - 'group_avatar_height' => array('USINT', 0), - 'group_rank' => array('UINT', 0), - 'group_colour' => array('VCHAR:6', ''), - 'group_sig_chars' => array('UINT', 0), - 'group_receive_pm' => array('BOOL', 0), - 'group_message_limit' => array('UINT', 0), - 'group_max_recipients' => array('UINT', 0), - 'group_legend' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'group_id', - 'KEYS' => array( - 'group_legend_name' => array('INDEX', array('group_legend', 'group_name')), - ), - ); - - $schema_data['phpbb_icons'] = array( - 'COLUMNS' => array( - 'icons_id' => array('UINT', NULL, 'auto_increment'), - 'icons_url' => array('VCHAR', ''), - 'icons_width' => array('TINT:4', 0), - 'icons_height' => array('TINT:4', 0), - 'icons_order' => array('UINT', 0), - 'display_on_posting' => array('BOOL', 1), - ), - 'PRIMARY_KEY' => 'icons_id', - 'KEYS' => array( - 'display_on_posting' => array('INDEX', 'display_on_posting'), - ), - ); - - $schema_data['phpbb_lang'] = array( - 'COLUMNS' => array( - 'lang_id' => array('TINT:4', NULL, 'auto_increment'), - 'lang_iso' => array('VCHAR:30', ''), - 'lang_dir' => array('VCHAR:30', ''), - 'lang_english_name' => array('VCHAR_UNI:100', ''), - 'lang_local_name' => array('VCHAR_UNI:255', ''), - 'lang_author' => array('VCHAR_UNI:255', ''), - ), - 'PRIMARY_KEY' => 'lang_id', - 'KEYS' => array( - 'lang_iso' => array('INDEX', 'lang_iso'), - ), - ); - - $schema_data['phpbb_log'] = array( - 'COLUMNS' => array( - 'log_id' => array('UINT', NULL, 'auto_increment'), - 'log_type' => array('TINT:4', 0), - 'user_id' => array('UINT', 0), - 'forum_id' => array('UINT', 0), - 'topic_id' => array('UINT', 0), - 'reportee_id' => array('UINT', 0), - 'log_ip' => array('VCHAR:40', ''), - 'log_time' => array('TIMESTAMP', 0), - 'log_operation' => array('TEXT_UNI', ''), - 'log_data' => array('MTEXT_UNI', ''), - ), - 'PRIMARY_KEY' => 'log_id', - 'KEYS' => array( - 'log_type' => array('INDEX', 'log_type'), - 'log_time' => array('INDEX', 'log_time'), - 'forum_id' => array('INDEX', 'forum_id'), - 'topic_id' => array('INDEX', 'topic_id'), - 'reportee_id' => array('INDEX', 'reportee_id'), - 'user_id' => array('INDEX', 'user_id'), - ), - ); - - $schema_data['phpbb_login_attempts'] = array( - 'COLUMNS' => array( - 'attempt_ip' => array('VCHAR:40', ''), - 'attempt_browser' => array('VCHAR:150', ''), - 'attempt_forwarded_for' => array('VCHAR:255', ''), - 'attempt_time' => array('TIMESTAMP', 0), - 'user_id' => array('UINT', 0), - 'username' => array('VCHAR_UNI:255', 0), - 'username_clean' => array('VCHAR_CI', 0), - ), - 'KEYS' => array( - 'att_ip' => array('INDEX', array('attempt_ip', 'attempt_time')), - 'att_for' => array('INDEX', array('attempt_forwarded_for', 'attempt_time')), - 'att_time' => array('INDEX', array('attempt_time')), - 'user_id' => array('INDEX', 'user_id'), - ), - ); - - $schema_data['phpbb_moderator_cache'] = array( - 'COLUMNS' => array( - 'forum_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'username' => array('VCHAR_UNI:255', ''), - 'group_id' => array('UINT', 0), - 'group_name' => array('VCHAR_UNI', ''), - 'display_on_index' => array('BOOL', 1), - ), - 'KEYS' => array( - 'disp_idx' => array('INDEX', 'display_on_index'), - 'forum_id' => array('INDEX', 'forum_id'), - ), - ); - - $schema_data['phpbb_migrations'] = array( - 'COLUMNS' => array( - 'migration_name' => array('VCHAR', ''), - 'migration_depends_on' => array('TEXT', ''), - 'migration_schema_done' => array('BOOL', 0), - 'migration_data_done' => array('BOOL', 0), - 'migration_data_state' => array('TEXT', ''), - 'migration_start_time' => array('TIMESTAMP', 0), - 'migration_end_time' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => 'migration_name', - ); - - $schema_data['phpbb_modules'] = array( - 'COLUMNS' => array( - 'module_id' => array('UINT', NULL, 'auto_increment'), - 'module_enabled' => array('BOOL', 1), - 'module_display' => array('BOOL', 1), - 'module_basename' => array('VCHAR', ''), - 'module_class' => array('VCHAR:10', ''), - 'parent_id' => array('UINT', 0), - 'left_id' => array('UINT', 0), - 'right_id' => array('UINT', 0), - 'module_langname' => array('VCHAR', ''), - 'module_mode' => array('VCHAR', ''), - 'module_auth' => array('VCHAR', ''), - ), - 'PRIMARY_KEY' => 'module_id', - 'KEYS' => array( - 'left_right_id' => array('INDEX', array('left_id', 'right_id')), - 'module_enabled' => array('INDEX', 'module_enabled'), - 'class_left_id' => array('INDEX', array('module_class', 'left_id')), - ), - ); - - $schema_data['phpbb_notification_types'] = array( - 'COLUMNS' => array( - 'notification_type_id' => array('USINT', NULL, 'auto_increment'), - 'notification_type_name' => array('VCHAR:255', ''), - 'notification_type_enabled' => array('BOOL', 1), - ), - 'PRIMARY_KEY' => array('notification_type_id'), - 'KEYS' => array( - 'type' => array('UNIQUE', array('notification_type_name')), - ), - ); - - $schema_data['phpbb_notifications'] = array( - 'COLUMNS' => array( - 'notification_id' => array('UINT:10', NULL, 'auto_increment'), - 'notification_type_id' => array('USINT', 0), - 'item_id' => array('UINT', 0), - 'item_parent_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'notification_read' => array('BOOL', 0), - 'notification_time' => array('TIMESTAMP', 1), - 'notification_data' => array('TEXT_UNI', ''), - ), - 'PRIMARY_KEY' => 'notification_id', - 'KEYS' => array( - 'item_ident' => array('INDEX', array('notification_type_id', 'item_id')), - 'user' => array('INDEX', array('user_id', 'notification_read')), - ), - ); - - $schema_data['phpbb_poll_options'] = array( - 'COLUMNS' => array( - 'poll_option_id' => array('TINT:4', 0), - 'topic_id' => array('UINT', 0), - 'poll_option_text' => array('TEXT_UNI', ''), - 'poll_option_total' => array('UINT', 0), - ), - 'KEYS' => array( - 'poll_opt_id' => array('INDEX', 'poll_option_id'), - 'topic_id' => array('INDEX', 'topic_id'), - ), - ); - - $schema_data['phpbb_poll_votes'] = array( - 'COLUMNS' => array( - 'topic_id' => array('UINT', 0), - 'poll_option_id' => array('TINT:4', 0), - 'vote_user_id' => array('UINT', 0), - 'vote_user_ip' => array('VCHAR:40', ''), - ), - 'KEYS' => array( - 'topic_id' => array('INDEX', 'topic_id'), - 'vote_user_id' => array('INDEX', 'vote_user_id'), - 'vote_user_ip' => array('INDEX', 'vote_user_ip'), - ), - ); - - $schema_data['phpbb_posts'] = array( - 'COLUMNS' => array( - 'post_id' => array('UINT', NULL, 'auto_increment'), - 'topic_id' => array('UINT', 0), - 'forum_id' => array('UINT', 0), - 'poster_id' => array('UINT', 0), - 'icon_id' => array('UINT', 0), - 'poster_ip' => array('VCHAR:40', ''), - 'post_time' => array('TIMESTAMP', 0), - 'post_visibility' => array('TINT:3', 0), - 'post_reported' => array('BOOL', 0), - 'enable_bbcode' => array('BOOL', 1), - 'enable_smilies' => array('BOOL', 1), - 'enable_magic_url' => array('BOOL', 1), - 'enable_sig' => array('BOOL', 1), - 'post_username' => array('VCHAR_UNI:255', ''), - 'post_subject' => array('STEXT_UNI', '', 'true_sort'), - 'post_text' => array('MTEXT_UNI', ''), - 'post_checksum' => array('VCHAR:32', ''), - 'post_attachment' => array('BOOL', 0), - 'bbcode_bitfield' => array('VCHAR:255', ''), - 'bbcode_uid' => array('VCHAR:8', ''), - 'post_postcount' => array('BOOL', 1), - 'post_edit_time' => array('TIMESTAMP', 0), - 'post_edit_reason' => array('STEXT_UNI', ''), - 'post_edit_user' => array('UINT', 0), - 'post_edit_count' => array('USINT', 0), - 'post_edit_locked' => array('BOOL', 0), - 'post_delete_time' => array('TIMESTAMP', 0), - 'post_delete_reason' => array('STEXT_UNI', ''), - 'post_delete_user' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'post_id', - 'KEYS' => array( - 'forum_id' => array('INDEX', 'forum_id'), - 'topic_id' => array('INDEX', 'topic_id'), - 'poster_ip' => array('INDEX', 'poster_ip'), - 'poster_id' => array('INDEX', 'poster_id'), - 'post_visibility' => array('INDEX', 'post_visibility'), - 'post_username' => array('INDEX', 'post_username'), - 'tid_post_time' => array('INDEX', array('topic_id', 'post_time')), - ), - ); - - $schema_data['phpbb_privmsgs'] = array( - 'COLUMNS' => array( - 'msg_id' => array('UINT', NULL, 'auto_increment'), - 'root_level' => array('UINT', 0), - 'author_id' => array('UINT', 0), - 'icon_id' => array('UINT', 0), - 'author_ip' => array('VCHAR:40', ''), - 'message_time' => array('TIMESTAMP', 0), - 'enable_bbcode' => array('BOOL', 1), - 'enable_smilies' => array('BOOL', 1), - 'enable_magic_url' => array('BOOL', 1), - 'enable_sig' => array('BOOL', 1), - 'message_subject' => array('STEXT_UNI', ''), - 'message_text' => array('MTEXT_UNI', ''), - 'message_edit_reason' => array('STEXT_UNI', ''), - 'message_edit_user' => array('UINT', 0), - 'message_attachment' => array('BOOL', 0), - 'bbcode_bitfield' => array('VCHAR:255', ''), - 'bbcode_uid' => array('VCHAR:8', ''), - 'message_edit_time' => array('TIMESTAMP', 0), - 'message_edit_count' => array('USINT', 0), - 'to_address' => array('TEXT_UNI', ''), - 'bcc_address' => array('TEXT_UNI', ''), - 'message_reported' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => 'msg_id', - 'KEYS' => array( - 'author_ip' => array('INDEX', 'author_ip'), - 'message_time' => array('INDEX', 'message_time'), - 'author_id' => array('INDEX', 'author_id'), - 'root_level' => array('INDEX', 'root_level'), - ), - ); - - $schema_data['phpbb_privmsgs_folder'] = array( - 'COLUMNS' => array( - 'folder_id' => array('UINT', NULL, 'auto_increment'), - 'user_id' => array('UINT', 0), - 'folder_name' => array('VCHAR_UNI', ''), - 'pm_count' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'folder_id', - 'KEYS' => array( - 'user_id' => array('INDEX', 'user_id'), - ), - ); - - $schema_data['phpbb_privmsgs_rules'] = array( - 'COLUMNS' => array( - 'rule_id' => array('UINT', NULL, 'auto_increment'), - 'user_id' => array('UINT', 0), - 'rule_check' => array('UINT', 0), - 'rule_connection' => array('UINT', 0), - 'rule_string' => array('VCHAR_UNI', ''), - 'rule_user_id' => array('UINT', 0), - 'rule_group_id' => array('UINT', 0), - 'rule_action' => array('UINT', 0), - 'rule_folder_id' => array('INT:11', 0), - ), - 'PRIMARY_KEY' => 'rule_id', - 'KEYS' => array( - 'user_id' => array('INDEX', 'user_id'), - ), - ); - - $schema_data['phpbb_privmsgs_to'] = array( - 'COLUMNS' => array( - 'msg_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'author_id' => array('UINT', 0), - 'pm_deleted' => array('BOOL', 0), - 'pm_new' => array('BOOL', 1), - 'pm_unread' => array('BOOL', 1), - 'pm_replied' => array('BOOL', 0), - 'pm_marked' => array('BOOL', 0), - 'pm_forwarded' => array('BOOL', 0), - 'folder_id' => array('INT:11', 0), - ), - 'KEYS' => array( - 'msg_id' => array('INDEX', 'msg_id'), - 'author_id' => array('INDEX', 'author_id'), - 'usr_flder_id' => array('INDEX', array('user_id', 'folder_id')), - ), - ); - - $schema_data['phpbb_profile_fields'] = array( - 'COLUMNS' => array( - 'field_id' => array('UINT', NULL, 'auto_increment'), - 'field_name' => array('VCHAR_UNI', ''), - 'field_type' => array('TINT:4', 0), - 'field_ident' => array('VCHAR:20', ''), - 'field_length' => array('VCHAR:20', ''), - 'field_minlen' => array('VCHAR', ''), - 'field_maxlen' => array('VCHAR', ''), - 'field_novalue' => array('VCHAR_UNI', ''), - 'field_default_value' => array('VCHAR_UNI', ''), - 'field_validation' => array('VCHAR_UNI:20', ''), - 'field_required' => array('BOOL', 0), - 'field_show_novalue' => array('BOOL', 0), - 'field_show_on_reg' => array('BOOL', 0), - 'field_show_on_pm' => array('BOOL', 0), - 'field_show_on_vt' => array('BOOL', 0), - 'field_show_profile' => array('BOOL', 0), - 'field_hide' => array('BOOL', 0), - 'field_no_view' => array('BOOL', 0), - 'field_active' => array('BOOL', 0), - 'field_order' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'field_id', - 'KEYS' => array( - 'fld_type' => array('INDEX', 'field_type'), - 'fld_ordr' => array('INDEX', 'field_order'), - ), - ); - - $schema_data['phpbb_profile_fields_data'] = array( - 'COLUMNS' => array( - 'user_id' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'user_id', - ); - - $schema_data['phpbb_profile_fields_lang'] = array( - 'COLUMNS' => array( - 'field_id' => array('UINT', 0), - 'lang_id' => array('UINT', 0), - 'option_id' => array('UINT', 0), - 'field_type' => array('TINT:4', 0), - 'lang_value' => array('VCHAR_UNI', ''), - ), - 'PRIMARY_KEY' => array('field_id', 'lang_id', 'option_id'), - ); - - $schema_data['phpbb_profile_lang'] = array( - 'COLUMNS' => array( - 'field_id' => array('UINT', 0), - 'lang_id' => array('UINT', 0), - 'lang_name' => array('VCHAR_UNI', ''), - 'lang_explain' => array('TEXT_UNI', ''), - 'lang_default_value' => array('VCHAR_UNI', ''), - ), - 'PRIMARY_KEY' => array('field_id', 'lang_id'), - ); - - $schema_data['phpbb_ranks'] = array( - 'COLUMNS' => array( - 'rank_id' => array('UINT', NULL, 'auto_increment'), - 'rank_title' => array('VCHAR_UNI', ''), - 'rank_min' => array('UINT', 0), - 'rank_special' => array('BOOL', 0), - 'rank_image' => array('VCHAR', ''), - ), - 'PRIMARY_KEY' => 'rank_id', - ); - - $schema_data['phpbb_reports'] = array( - 'COLUMNS' => array( - 'report_id' => array('UINT', NULL, 'auto_increment'), - 'reason_id' => array('USINT', 0), - 'post_id' => array('UINT', 0), - 'pm_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'user_notify' => array('BOOL', 0), - 'report_closed' => array('BOOL', 0), - 'report_time' => array('TIMESTAMP', 0), - 'report_text' => array('MTEXT_UNI', ''), - 'reported_post_text' => array('MTEXT_UNI', ''), - 'reported_post_uid' => array('VCHAR:8', ''), - 'reported_post_bitfield' => array('VCHAR:255', ''), - 'reported_post_enable_magic_url' => array('BOOL', 1), - 'reported_post_enable_smilies' => array('BOOL', 1), - 'reported_post_enable_bbcode' => array('BOOL', 1) - ), - 'PRIMARY_KEY' => 'report_id', - 'KEYS' => array( - 'post_id' => array('INDEX', 'post_id'), - 'pm_id' => array('INDEX', 'pm_id'), - ), - ); - - $schema_data['phpbb_reports_reasons'] = array( - 'COLUMNS' => array( - 'reason_id' => array('USINT', NULL, 'auto_increment'), - 'reason_title' => array('VCHAR_UNI', ''), - 'reason_description' => array('MTEXT_UNI', ''), - 'reason_order' => array('USINT', 0), - ), - 'PRIMARY_KEY' => 'reason_id', - ); - - $schema_data['phpbb_search_results'] = array( - 'COLUMNS' => array( - 'search_key' => array('VCHAR:32', ''), - 'search_time' => array('TIMESTAMP', 0), - 'search_keywords' => array('MTEXT_UNI', ''), - 'search_authors' => array('MTEXT', ''), - ), - 'PRIMARY_KEY' => 'search_key', - ); - - $schema_data['phpbb_search_wordlist'] = array( - 'COLUMNS' => array( - 'word_id' => array('UINT', NULL, 'auto_increment'), - 'word_text' => array('VCHAR_UNI', ''), - 'word_common' => array('BOOL', 0), - 'word_count' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'word_id', - 'KEYS' => array( - 'wrd_txt' => array('UNIQUE', 'word_text'), - 'wrd_cnt' => array('INDEX', 'word_count'), - ), - ); - - $schema_data['phpbb_search_wordmatch'] = array( - 'COLUMNS' => array( - 'post_id' => array('UINT', 0), - 'word_id' => array('UINT', 0), - 'title_match' => array('BOOL', 0), - ), - 'KEYS' => array( - 'unq_mtch' => array('UNIQUE', array('word_id', 'post_id', 'title_match')), - 'word_id' => array('INDEX', 'word_id'), - 'post_id' => array('INDEX', 'post_id'), - ), - ); - - $schema_data['phpbb_sessions'] = array( - 'COLUMNS' => array( - 'session_id' => array('CHAR:32', ''), - 'session_user_id' => array('UINT', 0), - 'session_forum_id' => array('UINT', 0), - 'session_last_visit' => array('TIMESTAMP', 0), - 'session_start' => array('TIMESTAMP', 0), - 'session_time' => array('TIMESTAMP', 0), - 'session_ip' => array('VCHAR:40', ''), - 'session_browser' => array('VCHAR:150', ''), - 'session_forwarded_for' => array('VCHAR:255', ''), - 'session_page' => array('VCHAR_UNI', ''), - 'session_viewonline' => array('BOOL', 1), - 'session_autologin' => array('BOOL', 0), - 'session_admin' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => 'session_id', - 'KEYS' => array( - 'session_time' => array('INDEX', 'session_time'), - 'session_user_id' => array('INDEX', 'session_user_id'), - 'session_fid' => array('INDEX', 'session_forum_id'), - ), - ); - - $schema_data['phpbb_sessions_keys'] = array( - 'COLUMNS' => array( - 'key_id' => array('CHAR:32', ''), - 'user_id' => array('UINT', 0), - 'last_ip' => array('VCHAR:40', ''), - 'last_login' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => array('key_id', 'user_id'), - 'KEYS' => array( - 'last_login' => array('INDEX', 'last_login'), - ), - ); - - $schema_data['phpbb_sitelist'] = array( - 'COLUMNS' => array( - 'site_id' => array('UINT', NULL, 'auto_increment'), - 'site_ip' => array('VCHAR:40', ''), - 'site_hostname' => array('VCHAR', ''), - 'ip_exclude' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => 'site_id', - ); - - $schema_data['phpbb_smilies'] = array( - 'COLUMNS' => array( - 'smiley_id' => array('UINT', NULL, 'auto_increment'), - // We may want to set 'code' to VCHAR:50 or check if unicode support is possible... at the moment only ASCII characters are allowed. - 'code' => array('VCHAR_UNI:50', ''), - 'emotion' => array('VCHAR_UNI:50', ''), - 'smiley_url' => array('VCHAR:50', ''), - 'smiley_width' => array('USINT', 0), - 'smiley_height' => array('USINT', 0), - 'smiley_order' => array('UINT', 0), - 'display_on_posting'=> array('BOOL', 1), - ), - 'PRIMARY_KEY' => 'smiley_id', - 'KEYS' => array( - 'display_on_post' => array('INDEX', 'display_on_posting'), - ), - ); - - $schema_data['phpbb_styles'] = array( - 'COLUMNS' => array( - 'style_id' => array('UINT', NULL, 'auto_increment'), - 'style_name' => array('VCHAR_UNI:255', ''), - 'style_copyright' => array('VCHAR_UNI', ''), - 'style_active' => array('BOOL', 1), - 'style_path' => array('VCHAR:100', ''), - 'bbcode_bitfield' => array('VCHAR:255', 'kNg='), - 'style_parent_id' => array('UINT:4', 0), - 'style_parent_tree' => array('TEXT', ''), - ), - 'PRIMARY_KEY' => 'style_id', - 'KEYS' => array( - 'style_name' => array('UNIQUE', 'style_name'), - ), - ); - - $schema_data['phpbb_teampage'] = array( - 'COLUMNS' => array( - 'teampage_id' => array('UINT', NULL, 'auto_increment'), - 'group_id' => array('UINT', 0), - 'teampage_name' => array('VCHAR_UNI:255', ''), - 'teampage_position' => array('UINT', 0), - 'teampage_parent' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'teampage_id', - ); - - $schema_data['phpbb_topics'] = array( - 'COLUMNS' => array( - 'topic_id' => array('UINT', NULL, 'auto_increment'), - 'forum_id' => array('UINT', 0), - 'icon_id' => array('UINT', 0), - 'topic_attachment' => array('BOOL', 0), - 'topic_visibility' => array('TINT:3', 0), - 'topic_reported' => array('BOOL', 0), - 'topic_title' => array('STEXT_UNI', '', 'true_sort'), - 'topic_poster' => array('UINT', 0), - 'topic_time' => array('TIMESTAMP', 0), - 'topic_time_limit' => array('TIMESTAMP', 0), - 'topic_views' => array('UINT', 0), - 'topic_posts_approved' => array('UINT', 0), - 'topic_posts_unapproved' => array('UINT', 0), - 'topic_posts_softdeleted' => array('UINT', 0), - 'topic_status' => array('TINT:3', 0), - 'topic_type' => array('TINT:3', 0), - 'topic_first_post_id' => array('UINT', 0), - 'topic_first_poster_name' => array('VCHAR_UNI', ''), - 'topic_first_poster_colour' => array('VCHAR:6', ''), - 'topic_last_post_id' => array('UINT', 0), - 'topic_last_poster_id' => array('UINT', 0), - 'topic_last_poster_name' => array('VCHAR_UNI', ''), - 'topic_last_poster_colour' => array('VCHAR:6', ''), - 'topic_last_post_subject' => array('STEXT_UNI', ''), - 'topic_last_post_time' => array('TIMESTAMP', 0), - 'topic_last_view_time' => array('TIMESTAMP', 0), - 'topic_moved_id' => array('UINT', 0), - 'topic_bumped' => array('BOOL', 0), - 'topic_bumper' => array('UINT', 0), - 'poll_title' => array('STEXT_UNI', ''), - 'poll_start' => array('TIMESTAMP', 0), - 'poll_length' => array('TIMESTAMP', 0), - 'poll_max_options' => array('TINT:4', 1), - 'poll_last_vote' => array('TIMESTAMP', 0), - 'poll_vote_change' => array('BOOL', 0), - 'topic_delete_time' => array('TIMESTAMP', 0), - 'topic_delete_reason' => array('STEXT_UNI', ''), - 'topic_delete_user' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'topic_id', - 'KEYS' => array( - 'forum_id' => array('INDEX', 'forum_id'), - 'forum_id_type' => array('INDEX', array('forum_id', 'topic_type')), - 'last_post_time' => array('INDEX', 'topic_last_post_time'), - 'topic_visibility' => array('INDEX', 'topic_visibility'), - 'forum_appr_last' => array('INDEX', array('forum_id', 'topic_visibility', 'topic_last_post_id')), - 'fid_time_moved' => array('INDEX', array('forum_id', 'topic_last_post_time', 'topic_moved_id')), - ), - ); - - $schema_data['phpbb_topics_track'] = array( - 'COLUMNS' => array( - 'user_id' => array('UINT', 0), - 'topic_id' => array('UINT', 0), - 'forum_id' => array('UINT', 0), - 'mark_time' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => array('user_id', 'topic_id'), - 'KEYS' => array( - 'topic_id' => array('INDEX', 'topic_id'), - 'forum_id' => array('INDEX', 'forum_id'), - ), - ); - - $schema_data['phpbb_topics_posted'] = array( - 'COLUMNS' => array( - 'user_id' => array('UINT', 0), - 'topic_id' => array('UINT', 0), - 'topic_posted' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => array('user_id', 'topic_id'), - ); - - $schema_data['phpbb_topics_watch'] = array( - 'COLUMNS' => array( - 'topic_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'notify_status' => array('BOOL', 0), - ), - 'KEYS' => array( - 'topic_id' => array('INDEX', 'topic_id'), - 'user_id' => array('INDEX', 'user_id'), - 'notify_stat' => array('INDEX', 'notify_status'), - ), - ); - - $schema_data['phpbb_user_notifications'] = array( - 'COLUMNS' => array( - 'item_type' => array('VCHAR:255', ''), - 'item_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'method' => array('VCHAR:255', ''), - 'notify' => array('BOOL', 1), - ), - ); - - $schema_data['phpbb_user_group'] = array( - 'COLUMNS' => array( - 'group_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'group_leader' => array('BOOL', 0), - 'user_pending' => array('BOOL', 1), - ), - 'KEYS' => array( - 'group_id' => array('INDEX', 'group_id'), - 'user_id' => array('INDEX', 'user_id'), - 'group_leader' => array('INDEX', 'group_leader'), - ), - ); - - $schema_data['phpbb_users'] = array( - 'COLUMNS' => array( - 'user_id' => array('UINT', NULL, 'auto_increment'), - 'user_type' => array('TINT:2', 0), - 'group_id' => array('UINT', 3), - 'user_permissions' => array('MTEXT', ''), - 'user_perm_from' => array('UINT', 0), - 'user_ip' => array('VCHAR:40', ''), - 'user_regdate' => array('TIMESTAMP', 0), - 'username' => array('VCHAR_CI', ''), - 'username_clean' => array('VCHAR_CI', ''), - 'user_password' => array('VCHAR_UNI:40', ''), - 'user_passchg' => array('TIMESTAMP', 0), - 'user_pass_convert' => array('BOOL', 0), - 'user_email' => array('VCHAR_UNI:100', ''), - 'user_email_hash' => array('BINT', 0), - 'user_birthday' => array('VCHAR:10', ''), - 'user_lastvisit' => array('TIMESTAMP', 0), - 'user_lastmark' => array('TIMESTAMP', 0), - 'user_lastpost_time' => array('TIMESTAMP', 0), - 'user_lastpage' => array('VCHAR_UNI:200', ''), - 'user_last_confirm_key' => array('VCHAR:10', ''), - 'user_last_search' => array('TIMESTAMP', 0), - 'user_warnings' => array('TINT:4', 0), - 'user_last_warning' => array('TIMESTAMP', 0), - 'user_login_attempts' => array('TINT:4', 0), - 'user_inactive_reason' => array('TINT:2', 0), - 'user_inactive_time' => array('TIMESTAMP', 0), - 'user_posts' => array('UINT', 0), - 'user_lang' => array('VCHAR:30', ''), - 'user_timezone' => array('VCHAR:100', 'UTC'), - 'user_dateformat' => array('VCHAR_UNI:30', 'd M Y H:i'), - 'user_style' => array('UINT', 0), - 'user_rank' => array('UINT', 0), - 'user_colour' => array('VCHAR:6', ''), - 'user_new_privmsg' => array('INT:4', 0), - 'user_unread_privmsg' => array('INT:4', 0), - 'user_last_privmsg' => array('TIMESTAMP', 0), - 'user_message_rules' => array('BOOL', 0), - 'user_full_folder' => array('INT:11', -3), - 'user_emailtime' => array('TIMESTAMP', 0), - 'user_topic_show_days' => array('USINT', 0), - 'user_topic_sortby_type' => array('VCHAR:1', 't'), - 'user_topic_sortby_dir' => array('VCHAR:1', 'd'), - 'user_post_show_days' => array('USINT', 0), - 'user_post_sortby_type' => array('VCHAR:1', 't'), - 'user_post_sortby_dir' => array('VCHAR:1', 'a'), - 'user_notify' => array('BOOL', 0), - 'user_notify_pm' => array('BOOL', 1), - 'user_notify_type' => array('TINT:4', 0), - 'user_allow_pm' => array('BOOL', 1), - 'user_allow_viewonline' => array('BOOL', 1), - 'user_allow_viewemail' => array('BOOL', 1), - 'user_allow_massemail' => array('BOOL', 1), - 'user_options' => array('UINT:11', 230271), - 'user_avatar' => array('VCHAR', ''), - 'user_avatar_type' => array('VCHAR:255', ''), - 'user_avatar_width' => array('USINT', 0), - 'user_avatar_height' => array('USINT', 0), - 'user_sig' => array('MTEXT_UNI', ''), - 'user_sig_bbcode_uid' => array('VCHAR:8', ''), - 'user_sig_bbcode_bitfield' => array('VCHAR:255', ''), - 'user_from' => array('VCHAR_UNI:100', ''), - 'user_icq' => array('VCHAR:15', ''), - 'user_aim' => array('VCHAR_UNI', ''), - 'user_yim' => array('VCHAR_UNI', ''), - 'user_msnm' => array('VCHAR_UNI', ''), - 'user_jabber' => array('VCHAR_UNI', ''), - 'user_website' => array('VCHAR_UNI:200', ''), - 'user_occ' => array('TEXT_UNI', ''), - 'user_interests' => array('TEXT_UNI', ''), - 'user_actkey' => array('VCHAR:32', ''), - 'user_newpasswd' => array('VCHAR_UNI:40', ''), - 'user_form_salt' => array('VCHAR_UNI:32', ''), - 'user_new' => array('BOOL', 1), - 'user_reminded' => array('TINT:4', 0), - 'user_reminded_time' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => 'user_id', - 'KEYS' => array( - 'user_birthday' => array('INDEX', 'user_birthday'), - 'user_email_hash' => array('INDEX', 'user_email_hash'), - 'user_type' => array('INDEX', 'user_type'), - 'username_clean' => array('UNIQUE', 'username_clean'), - ), - ); - - $schema_data['phpbb_warnings'] = array( - 'COLUMNS' => array( - 'warning_id' => array('UINT', NULL, 'auto_increment'), - 'user_id' => array('UINT', 0), - 'post_id' => array('UINT', 0), - 'log_id' => array('UINT', 0), - 'warning_time' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => 'warning_id', - ); - - $schema_data['phpbb_words'] = array( - 'COLUMNS' => array( - 'word_id' => array('UINT', NULL, 'auto_increment'), - 'word' => array('VCHAR_UNI', ''), - 'replacement' => array('VCHAR_UNI', ''), - ), - 'PRIMARY_KEY' => 'word_id', - ); - - $schema_data['phpbb_zebra'] = array( - 'COLUMNS' => array( - 'user_id' => array('UINT', 0), - 'zebra_id' => array('UINT', 0), - 'friend' => array('BOOL', 0), - 'foe' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => array('user_id', 'zebra_id'), - ); - - return $schema_data; -} - - /** * Data put into the header for various dbms */ diff --git a/phpBB/develop/mysql_upgrader.php b/phpBB/develop/mysql_upgrader.php index f5e7e97400..340112fa38 100644 --- a/phpBB/develop/mysql_upgrader.php +++ b/phpBB/develop/mysql_upgrader.php @@ -56,68 +56,10 @@ echo "USE $dbname;$newline$newline"; @set_time_limit(0); -$schema_data = get_schema_struct(); -$dbms_type_map = array( - 'mysql_41' => array( - 'INT:' => 'int(%d)', - 'BINT' => 'bigint(20)', - 'UINT' => 'mediumint(8) UNSIGNED', - 'UINT:' => 'int(%d) UNSIGNED', - 'TINT:' => 'tinyint(%d)', - 'USINT' => 'smallint(4) UNSIGNED', - 'BOOL' => 'tinyint(1) UNSIGNED', - 'VCHAR' => 'varchar(255)', - 'VCHAR:' => 'varchar(%d)', - 'CHAR:' => 'char(%d)', - 'XSTEXT' => 'text', - 'XSTEXT_UNI'=> 'varchar(100)', - 'STEXT' => 'text', - 'STEXT_UNI' => 'varchar(255)', - 'TEXT' => 'text', - 'TEXT_UNI' => 'text', - 'MTEXT' => 'mediumtext', - 'MTEXT_UNI' => 'mediumtext', - 'TIMESTAMP' => 'int(11) UNSIGNED', - 'DECIMAL' => 'decimal(5,2)', - 'DECIMAL:' => 'decimal(%d,2)', - 'PDECIMAL' => 'decimal(6,3)', - 'PDECIMAL:' => 'decimal(%d,3)', - 'VCHAR_UNI' => 'varchar(255)', - 'VCHAR_UNI:'=> 'varchar(%d)', - 'VCHAR_CI' => 'varchar(255)', - 'VARBINARY' => 'varbinary(255)', - ), +require($phpbb_root_path . 'phpbb/db/schema_data.' . $phpEx); +require($phpbb_root_path . 'phpbb/db/tools.' . $phpEx); - 'mysql_40' => array( - 'INT:' => 'int(%d)', - 'BINT' => 'bigint(20)', - 'UINT' => 'mediumint(8) UNSIGNED', - 'UINT:' => 'int(%d) UNSIGNED', - 'TINT:' => 'tinyint(%d)', - 'USINT' => 'smallint(4) UNSIGNED', - 'BOOL' => 'tinyint(1) UNSIGNED', - 'VCHAR' => 'varbinary(255)', - 'VCHAR:' => 'varbinary(%d)', - 'CHAR:' => 'binary(%d)', - 'XSTEXT' => 'blob', - 'XSTEXT_UNI'=> 'blob', - 'STEXT' => 'blob', - 'STEXT_UNI' => 'blob', - 'TEXT' => 'blob', - 'TEXT_UNI' => 'blob', - 'MTEXT' => 'mediumblob', - 'MTEXT_UNI' => 'mediumblob', - 'TIMESTAMP' => 'int(11) UNSIGNED', - 'DECIMAL' => 'decimal(5,2)', - 'DECIMAL:' => 'decimal(%d,2)', - 'PDECIMAL' => 'decimal(6,3)', - 'PDECIMAL:' => 'decimal(%d,3)', - 'VCHAR_UNI' => 'blob', - 'VCHAR_UNI:'=> array('varbinary(%d)', 'limit' => array('mult', 3, 255, 'blob')), - 'VCHAR_CI' => 'blob', - 'VARBINARY' => 'varbinary(255)', - ), -); +$dbms_type_map = phpbb_db_tools::get_dbms_type_map(); foreach ($schema_data as $table_name => $table_data) { @@ -255,1090 +197,3 @@ foreach ($schema_data as $table_name => $table_data) echo "ALTER TABLE $table_name ADD FULLTEXT (post_subject), ADD FULLTEXT (post_text), ADD FULLTEXT post_content (post_subject, post_text);{$newline}"; } } - -/** -* Define the basic structure -* The format: -* array('{TABLE_NAME}' => {TABLE_DATA}) -* {TABLE_DATA}: -* COLUMNS = array({column_name} = array({column_type}, {default}, {auto_increment})) -* PRIMARY_KEY = {column_name(s)} -* KEYS = array({key_name} = array({key_type}, {column_name(s)})), -* -* Column Types: -* INT:x => SIGNED int(x) -* BINT => BIGINT -* UINT => mediumint(8) UNSIGNED -* UINT:x => int(x) UNSIGNED -* TINT:x => tinyint(x) -* USINT => smallint(4) UNSIGNED (for _order columns) -* BOOL => tinyint(1) UNSIGNED -* VCHAR => varchar(255) -* CHAR:x => char(x) -* XSTEXT_UNI => text for storing 100 characters (topic_title for example) -* STEXT_UNI => text for storing 255 characters (normal input field with a max of 255 single-byte chars) - same as VCHAR_UNI -* TEXT_UNI => text for storing 3000 characters (short text, descriptions, comments, etc.) -* MTEXT_UNI => mediumtext (post text, large text) -* VCHAR:x => varchar(x) -* TIMESTAMP => int(11) UNSIGNED -* DECIMAL => decimal number (5,2) -* DECIMAL: => decimal number (x,2) -* PDECIMAL => precision decimal number (6,3) -* PDECIMAL: => precision decimal number (x,3) -* VCHAR_UNI => varchar(255) BINARY -* VCHAR_CI => varchar_ci for postgresql, others VCHAR -*/ -function get_schema_struct() -{ - $schema_data = array(); - - $schema_data['phpbb_attachments'] = array( - 'COLUMNS' => array( - 'attach_id' => array('UINT', NULL, 'auto_increment'), - 'post_msg_id' => array('UINT', 0), - 'topic_id' => array('UINT', 0), - 'in_message' => array('BOOL', 0), - 'poster_id' => array('UINT', 0), - 'is_orphan' => array('BOOL', 1), - 'physical_filename' => array('VCHAR', ''), - 'real_filename' => array('VCHAR', ''), - 'download_count' => array('UINT', 0), - 'attach_comment' => array('TEXT_UNI', ''), - 'extension' => array('VCHAR:100', ''), - 'mimetype' => array('VCHAR:100', ''), - 'filesize' => array('UINT:20', 0), - 'filetime' => array('TIMESTAMP', 0), - 'thumbnail' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => 'attach_id', - 'KEYS' => array( - 'filetime' => array('INDEX', 'filetime'), - 'post_msg_id' => array('INDEX', 'post_msg_id'), - 'topic_id' => array('INDEX', 'topic_id'), - 'poster_id' => array('INDEX', 'poster_id'), - 'is_orphan' => array('INDEX', 'is_orphan'), - ), - ); - - $schema_data['phpbb_acl_groups'] = array( - 'COLUMNS' => array( - 'group_id' => array('UINT', 0), - 'forum_id' => array('UINT', 0), - 'auth_option_id' => array('UINT', 0), - 'auth_role_id' => array('UINT', 0), - 'auth_setting' => array('TINT:2', 0), - ), - 'KEYS' => array( - 'group_id' => array('INDEX', 'group_id'), - 'auth_opt_id' => array('INDEX', 'auth_option_id'), - 'auth_role_id' => array('INDEX', 'auth_role_id'), - ), - ); - - $schema_data['phpbb_acl_options'] = array( - 'COLUMNS' => array( - 'auth_option_id' => array('UINT', NULL, 'auto_increment'), - 'auth_option' => array('VCHAR:50', ''), - 'is_global' => array('BOOL', 0), - 'is_local' => array('BOOL', 0), - 'founder_only' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => 'auth_option_id', - 'KEYS' => array( - 'auth_option' => array('UNIQUE', 'auth_option'), - ), - ); - - $schema_data['phpbb_acl_roles'] = array( - 'COLUMNS' => array( - 'role_id' => array('UINT', NULL, 'auto_increment'), - 'role_name' => array('VCHAR_UNI', ''), - 'role_description' => array('TEXT_UNI', ''), - 'role_type' => array('VCHAR:10', ''), - 'role_order' => array('USINT', 0), - ), - 'PRIMARY_KEY' => 'role_id', - 'KEYS' => array( - 'role_type' => array('INDEX', 'role_type'), - 'role_order' => array('INDEX', 'role_order'), - ), - ); - - $schema_data['phpbb_acl_roles_data'] = array( - 'COLUMNS' => array( - 'role_id' => array('UINT', 0), - 'auth_option_id' => array('UINT', 0), - 'auth_setting' => array('TINT:2', 0), - ), - 'PRIMARY_KEY' => array('role_id', 'auth_option_id'), - 'KEYS' => array( - 'ath_op_id' => array('INDEX', 'auth_option_id'), - ), - ); - - $schema_data['phpbb_acl_users'] = array( - 'COLUMNS' => array( - 'user_id' => array('UINT', 0), - 'forum_id' => array('UINT', 0), - 'auth_option_id' => array('UINT', 0), - 'auth_role_id' => array('UINT', 0), - 'auth_setting' => array('TINT:2', 0), - ), - 'KEYS' => array( - 'user_id' => array('INDEX', 'user_id'), - 'auth_option_id' => array('INDEX', 'auth_option_id'), - 'auth_role_id' => array('INDEX', 'auth_role_id'), - ), - ); - - $schema_data['phpbb_banlist'] = array( - 'COLUMNS' => array( - 'ban_id' => array('UINT', NULL, 'auto_increment'), - 'ban_userid' => array('UINT', 0), - 'ban_ip' => array('VCHAR:40', ''), - 'ban_email' => array('VCHAR_UNI:100', ''), - 'ban_start' => array('TIMESTAMP', 0), - 'ban_end' => array('TIMESTAMP', 0), - 'ban_exclude' => array('BOOL', 0), - 'ban_reason' => array('VCHAR_UNI', ''), - 'ban_give_reason' => array('VCHAR_UNI', ''), - ), - 'PRIMARY_KEY' => 'ban_id', - 'KEYS' => array( - 'ban_end' => array('INDEX', 'ban_end'), - 'ban_user' => array('INDEX', array('ban_userid', 'ban_exclude')), - 'ban_email' => array('INDEX', array('ban_email', 'ban_exclude')), - 'ban_ip' => array('INDEX', array('ban_ip', 'ban_exclude')), - ), - ); - - $schema_data['phpbb_bbcodes'] = array( - 'COLUMNS' => array( - 'bbcode_id' => array('USINT', 0), - 'bbcode_tag' => array('VCHAR:16', ''), - 'bbcode_helpline' => array('VCHAR_UNI', ''), - 'display_on_posting' => array('BOOL', 0), - 'bbcode_match' => array('TEXT_UNI', ''), - 'bbcode_tpl' => array('MTEXT_UNI', ''), - 'first_pass_match' => array('MTEXT_UNI', ''), - 'first_pass_replace' => array('MTEXT_UNI', ''), - 'second_pass_match' => array('MTEXT_UNI', ''), - 'second_pass_replace' => array('MTEXT_UNI', ''), - ), - 'PRIMARY_KEY' => 'bbcode_id', - 'KEYS' => array( - 'display_on_post' => array('INDEX', 'display_on_posting'), - ), - ); - - $schema_data['phpbb_bookmarks'] = array( - 'COLUMNS' => array( - 'topic_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - ), - 'PRIMARY_KEY' => array('topic_id', 'user_id'), - ); - - $schema_data['phpbb_bots'] = array( - 'COLUMNS' => array( - 'bot_id' => array('UINT', NULL, 'auto_increment'), - 'bot_active' => array('BOOL', 1), - 'bot_name' => array('STEXT_UNI', ''), - 'user_id' => array('UINT', 0), - 'bot_agent' => array('VCHAR', ''), - 'bot_ip' => array('VCHAR', ''), - ), - 'PRIMARY_KEY' => 'bot_id', - 'KEYS' => array( - 'bot_active' => array('INDEX', 'bot_active'), - ), - ); - - $schema_data['phpbb_config'] = array( - 'COLUMNS' => array( - 'config_name' => array('VCHAR', ''), - 'config_value' => array('VCHAR_UNI', ''), - 'is_dynamic' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => 'config_name', - 'KEYS' => array( - 'is_dynamic' => array('INDEX', 'is_dynamic'), - ), - ); - - $schema_data['phpbb_confirm'] = array( - 'COLUMNS' => array( - 'confirm_id' => array('CHAR:32', ''), - 'session_id' => array('CHAR:32', ''), - 'confirm_type' => array('TINT:3', 0), - 'code' => array('VCHAR:8', ''), - 'seed' => array('UINT:10', 0), - 'attempts' => array('UINT', 0), - ), - 'PRIMARY_KEY' => array('session_id', 'confirm_id'), - 'KEYS' => array( - 'confirm_type' => array('INDEX', 'confirm_type'), - ), - ); - - $schema_data['phpbb_disallow'] = array( - 'COLUMNS' => array( - 'disallow_id' => array('UINT', NULL, 'auto_increment'), - 'disallow_username' => array('VCHAR_UNI:255', ''), - ), - 'PRIMARY_KEY' => 'disallow_id', - ); - - $schema_data['phpbb_drafts'] = array( - 'COLUMNS' => array( - 'draft_id' => array('UINT', NULL, 'auto_increment'), - 'user_id' => array('UINT', 0), - 'topic_id' => array('UINT', 0), - 'forum_id' => array('UINT', 0), - 'save_time' => array('TIMESTAMP', 0), - 'draft_subject' => array('STEXT_UNI', ''), - 'draft_message' => array('MTEXT_UNI', ''), - ), - 'PRIMARY_KEY' => 'draft_id', - 'KEYS' => array( - 'save_time' => array('INDEX', 'save_time'), - ), - ); - - $schema_data['phpbb_extensions'] = array( - 'COLUMNS' => array( - 'extension_id' => array('UINT', NULL, 'auto_increment'), - 'group_id' => array('UINT', 0), - 'extension' => array('VCHAR:100', ''), - ), - 'PRIMARY_KEY' => 'extension_id', - ); - - $schema_data['phpbb_extension_groups'] = array( - 'COLUMNS' => array( - 'group_id' => array('UINT', NULL, 'auto_increment'), - 'group_name' => array('VCHAR_UNI', ''), - 'cat_id' => array('TINT:2', 0), - 'allow_group' => array('BOOL', 0), - 'download_mode' => array('BOOL', 1), - 'upload_icon' => array('VCHAR', ''), - 'max_filesize' => array('UINT:20', 0), - 'allowed_forums' => array('TEXT', ''), - 'allow_in_pm' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => 'group_id', - ); - - $schema_data['phpbb_forums'] = array( - 'COLUMNS' => array( - 'forum_id' => array('UINT', NULL, 'auto_increment'), - 'parent_id' => array('UINT', 0), - 'left_id' => array('UINT', 0), - 'right_id' => array('UINT', 0), - 'forum_parents' => array('MTEXT', ''), - 'forum_name' => array('STEXT_UNI', ''), - 'forum_desc' => array('TEXT_UNI', ''), - 'forum_desc_bitfield' => array('VCHAR:255', ''), - 'forum_desc_options' => array('UINT:11', 7), - 'forum_desc_uid' => array('VCHAR:8', ''), - 'forum_link' => array('VCHAR_UNI', ''), - 'forum_password' => array('VCHAR_UNI:40', ''), - 'forum_style' => array('UINT', 0), - 'forum_image' => array('VCHAR', ''), - 'forum_rules' => array('TEXT_UNI', ''), - 'forum_rules_link' => array('VCHAR_UNI', ''), - 'forum_rules_bitfield' => array('VCHAR:255', ''), - 'forum_rules_options' => array('UINT:11', 7), - 'forum_rules_uid' => array('VCHAR:8', ''), - 'forum_topics_per_page' => array('TINT:4', 0), - 'forum_type' => array('TINT:4', 0), - 'forum_status' => array('TINT:4', 0), - 'forum_posts_approved' => array('UINT', 0), - 'forum_posts_unapproved' => array('UINT', 0), - 'forum_posts_softdeleted' => array('UINT', 0), - 'forum_topics_approved' => array('UINT', 0), - 'forum_topics_unapproved' => array('UINT', 0), - 'forum_topics_softdeleted' => array('UINT', 0), - 'forum_last_post_id' => array('UINT', 0), - 'forum_last_poster_id' => array('UINT', 0), - 'forum_last_post_subject' => array('STEXT_UNI', ''), - 'forum_last_post_time' => array('TIMESTAMP', 0), - 'forum_last_poster_name'=> array('VCHAR_UNI', ''), - 'forum_last_poster_colour'=> array('VCHAR:6', ''), - 'forum_flags' => array('TINT:4', 32), - 'forum_options' => array('UINT:20', 0), - 'display_subforum_list' => array('BOOL', 1), - 'display_on_index' => array('BOOL', 1), - 'enable_indexing' => array('BOOL', 1), - 'enable_icons' => array('BOOL', 1), - 'enable_prune' => array('BOOL', 0), - 'prune_next' => array('TIMESTAMP', 0), - 'prune_days' => array('UINT', 0), - 'prune_viewed' => array('UINT', 0), - 'prune_freq' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'forum_id', - 'KEYS' => array( - 'left_right_id' => array('INDEX', array('left_id', 'right_id')), - 'forum_lastpost_id' => array('INDEX', 'forum_last_post_id'), - ), - ); - - $schema_data['phpbb_forums_access'] = array( - 'COLUMNS' => array( - 'forum_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'session_id' => array('CHAR:32', ''), - ), - 'PRIMARY_KEY' => array('forum_id', 'user_id', 'session_id'), - ); - - $schema_data['phpbb_forums_track'] = array( - 'COLUMNS' => array( - 'user_id' => array('UINT', 0), - 'forum_id' => array('UINT', 0), - 'mark_time' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => array('user_id', 'forum_id'), - ); - - $schema_data['phpbb_forums_watch'] = array( - 'COLUMNS' => array( - 'forum_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'notify_status' => array('BOOL', 0), - ), - 'KEYS' => array( - 'forum_id' => array('INDEX', 'forum_id'), - 'user_id' => array('INDEX', 'user_id'), - 'notify_stat' => array('INDEX', 'notify_status'), - ), - ); - - $schema_data['phpbb_groups'] = array( - 'COLUMNS' => array( - 'group_id' => array('UINT', NULL, 'auto_increment'), - 'group_type' => array('TINT:4', 1), - 'group_founder_manage' => array('BOOL', 0), - 'group_skip_auth' => array('BOOL', 0), - 'group_name' => array('VCHAR_CI', ''), - 'group_desc' => array('TEXT_UNI', ''), - 'group_desc_bitfield' => array('VCHAR:255', ''), - 'group_desc_options' => array('UINT:11', 7), - 'group_desc_uid' => array('VCHAR:8', ''), - 'group_display' => array('BOOL', 0), - 'group_avatar' => array('VCHAR', ''), - 'group_avatar_type' => array('TINT:2', 0), - 'group_avatar_width' => array('USINT', 0), - 'group_avatar_height' => array('USINT', 0), - 'group_rank' => array('UINT', 0), - 'group_colour' => array('VCHAR:6', ''), - 'group_sig_chars' => array('UINT', 0), - 'group_receive_pm' => array('BOOL', 0), - 'group_message_limit' => array('UINT', 0), - 'group_max_recipients' => array('UINT', 0), - 'group_legend' => array('BOOL', 1), - ), - 'PRIMARY_KEY' => 'group_id', - 'KEYS' => array( - 'group_legend_name' => array('INDEX', array('group_legend', 'group_name')), - ), - ); - - $schema_data['phpbb_icons'] = array( - 'COLUMNS' => array( - 'icons_id' => array('UINT', NULL, 'auto_increment'), - 'icons_url' => array('VCHAR', ''), - 'icons_width' => array('TINT:4', 0), - 'icons_height' => array('TINT:4', 0), - 'icons_order' => array('UINT', 0), - 'display_on_posting' => array('BOOL', 1), - ), - 'PRIMARY_KEY' => 'icons_id', - 'KEYS' => array( - 'display_on_posting' => array('INDEX', 'display_on_posting'), - ), - ); - - $schema_data['phpbb_lang'] = array( - 'COLUMNS' => array( - 'lang_id' => array('TINT:4', NULL, 'auto_increment'), - 'lang_iso' => array('VCHAR:30', ''), - 'lang_dir' => array('VCHAR:30', ''), - 'lang_english_name' => array('VCHAR_UNI:100', ''), - 'lang_local_name' => array('VCHAR_UNI:255', ''), - 'lang_author' => array('VCHAR_UNI:255', ''), - ), - 'PRIMARY_KEY' => 'lang_id', - 'KEYS' => array( - 'lang_iso' => array('INDEX', 'lang_iso'), - ), - ); - - $schema_data['phpbb_log'] = array( - 'COLUMNS' => array( - 'log_id' => array('UINT', NULL, 'auto_increment'), - 'log_type' => array('TINT:4', 0), - 'user_id' => array('UINT', 0), - 'forum_id' => array('UINT', 0), - 'topic_id' => array('UINT', 0), - 'reportee_id' => array('UINT', 0), - 'log_ip' => array('VCHAR:40', ''), - 'log_time' => array('TIMESTAMP', 0), - 'log_operation' => array('TEXT_UNI', ''), - 'log_data' => array('MTEXT_UNI', ''), - ), - 'PRIMARY_KEY' => 'log_id', - 'KEYS' => array( - 'log_type' => array('INDEX', 'log_type'), - 'log_time' => array('INDEX', 'log_time'), - 'forum_id' => array('INDEX', 'forum_id'), - 'topic_id' => array('INDEX', 'topic_id'), - 'reportee_id' => array('INDEX', 'reportee_id'), - 'user_id' => array('INDEX', 'user_id'), - ), - ); - - $schema_data['phpbb_login_attempts'] = array( - 'COLUMNS' => array( - 'attempt_ip' => array('VCHAR:40', ''), - 'attempt_browser' => array('VCHAR:150', ''), - 'attempt_forwarded_for' => array('VCHAR:255', ''), - 'attempt_time' => array('TIMESTAMP', 0), - 'user_id' => array('UINT', 0), - 'username' => array('VCHAR_UNI:255', 0), - 'username_clean' => array('VCHAR_CI', 0), - ), - 'KEYS' => array( - 'att_ip' => array('INDEX', array('attempt_ip', 'attempt_time')), - 'att_for' => array('INDEX', array('attempt_forwarded_for', 'attempt_time')), - 'att_time' => array('INDEX', array('attempt_time')), - 'user_id' => array('INDEX', 'user_id'), - ), - ); - - $schema_data['phpbb_moderator_cache'] = array( - 'COLUMNS' => array( - 'forum_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'username' => array('VCHAR_UNI:255', ''), - 'group_id' => array('UINT', 0), - 'group_name' => array('VCHAR_UNI', ''), - 'display_on_index' => array('BOOL', 1), - ), - 'KEYS' => array( - 'disp_idx' => array('INDEX', 'display_on_index'), - 'forum_id' => array('INDEX', 'forum_id'), - ), - ); - - $schema_data['phpbb_modules'] = array( - 'COLUMNS' => array( - 'module_id' => array('UINT', NULL, 'auto_increment'), - 'module_enabled' => array('BOOL', 1), - 'module_display' => array('BOOL', 1), - 'module_basename' => array('VCHAR', ''), - 'module_class' => array('VCHAR:10', ''), - 'parent_id' => array('UINT', 0), - 'left_id' => array('UINT', 0), - 'right_id' => array('UINT', 0), - 'module_langname' => array('VCHAR', ''), - 'module_mode' => array('VCHAR', ''), - 'module_auth' => array('VCHAR', ''), - ), - 'PRIMARY_KEY' => 'module_id', - 'KEYS' => array( - 'left_right_id' => array('INDEX', array('left_id', 'right_id')), - 'module_enabled' => array('INDEX', 'module_enabled'), - 'class_left_id' => array('INDEX', array('module_class', 'left_id')), - ), - ); - - $schema_data['phpbb_poll_options'] = array( - 'COLUMNS' => array( - 'poll_option_id' => array('TINT:4', 0), - 'topic_id' => array('UINT', 0), - 'poll_option_text' => array('TEXT_UNI', ''), - 'poll_option_total' => array('UINT', 0), - ), - 'KEYS' => array( - 'poll_opt_id' => array('INDEX', 'poll_option_id'), - 'topic_id' => array('INDEX', 'topic_id'), - ), - ); - - $schema_data['phpbb_poll_votes'] = array( - 'COLUMNS' => array( - 'topic_id' => array('UINT', 0), - 'poll_option_id' => array('TINT:4', 0), - 'vote_user_id' => array('UINT', 0), - 'vote_user_ip' => array('VCHAR:40', ''), - ), - 'KEYS' => array( - 'topic_id' => array('INDEX', 'topic_id'), - 'vote_user_id' => array('INDEX', 'vote_user_id'), - 'vote_user_ip' => array('INDEX', 'vote_user_ip'), - ), - ); - - $schema_data['phpbb_posts'] = array( - 'COLUMNS' => array( - 'post_id' => array('UINT', NULL, 'auto_increment'), - 'topic_id' => array('UINT', 0), - 'forum_id' => array('UINT', 0), - 'poster_id' => array('UINT', 0), - 'icon_id' => array('UINT', 0), - 'poster_ip' => array('VCHAR:40', ''), - 'post_time' => array('TIMESTAMP', 0), - 'post_visibility' => array('TINT:3', 0), - 'post_reported' => array('BOOL', 0), - 'enable_bbcode' => array('BOOL', 1), - 'enable_smilies' => array('BOOL', 1), - 'enable_magic_url' => array('BOOL', 1), - 'enable_sig' => array('BOOL', 1), - 'post_username' => array('VCHAR_UNI:255', ''), - 'post_subject' => array('STEXT_UNI', '', 'true_sort'), - 'post_text' => array('MTEXT_UNI', ''), - 'post_checksum' => array('VCHAR:32', ''), - 'post_attachment' => array('BOOL', 0), - 'bbcode_bitfield' => array('VCHAR:255', ''), - 'bbcode_uid' => array('VCHAR:8', ''), - 'post_postcount' => array('BOOL', 1), - 'post_edit_time' => array('TIMESTAMP', 0), - 'post_edit_reason' => array('STEXT_UNI', ''), - 'post_edit_user' => array('UINT', 0), - 'post_edit_count' => array('USINT', 0), - 'post_edit_locked' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => 'post_id', - 'KEYS' => array( - 'forum_id' => array('INDEX', 'forum_id'), - 'topic_id' => array('INDEX', 'topic_id'), - 'poster_ip' => array('INDEX', 'poster_ip'), - 'poster_id' => array('INDEX', 'poster_id'), - 'post_visibility' => array('INDEX', 'post_visibility'), - 'post_username' => array('INDEX', 'post_username'), - 'tid_post_time' => array('INDEX', array('topic_id', 'post_time')), - ), - ); - - $schema_data['phpbb_privmsgs'] = array( - 'COLUMNS' => array( - 'msg_id' => array('UINT', NULL, 'auto_increment'), - 'root_level' => array('UINT', 0), - 'author_id' => array('UINT', 0), - 'icon_id' => array('UINT', 0), - 'author_ip' => array('VCHAR:40', ''), - 'message_time' => array('TIMESTAMP', 0), - 'enable_bbcode' => array('BOOL', 1), - 'enable_smilies' => array('BOOL', 1), - 'enable_magic_url' => array('BOOL', 1), - 'enable_sig' => array('BOOL', 1), - 'message_subject' => array('STEXT_UNI', ''), - 'message_text' => array('MTEXT_UNI', ''), - 'message_edit_reason' => array('STEXT_UNI', ''), - 'message_edit_user' => array('UINT', 0), - 'message_attachment' => array('BOOL', 0), - 'bbcode_bitfield' => array('VCHAR:255', ''), - 'bbcode_uid' => array('VCHAR:8', ''), - 'message_edit_time' => array('TIMESTAMP', 0), - 'message_edit_count' => array('USINT', 0), - 'to_address' => array('TEXT_UNI', ''), - 'bcc_address' => array('TEXT_UNI', ''), - 'message_reported' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => 'msg_id', - 'KEYS' => array( - 'author_ip' => array('INDEX', 'author_ip'), - 'message_time' => array('INDEX', 'message_time'), - 'author_id' => array('INDEX', 'author_id'), - 'root_level' => array('INDEX', 'root_level'), - ), - ); - - $schema_data['phpbb_privmsgs_folder'] = array( - 'COLUMNS' => array( - 'folder_id' => array('UINT', NULL, 'auto_increment'), - 'user_id' => array('UINT', 0), - 'folder_name' => array('VCHAR_UNI', ''), - 'pm_count' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'folder_id', - 'KEYS' => array( - 'user_id' => array('INDEX', 'user_id'), - ), - ); - - $schema_data['phpbb_privmsgs_rules'] = array( - 'COLUMNS' => array( - 'rule_id' => array('UINT', NULL, 'auto_increment'), - 'user_id' => array('UINT', 0), - 'rule_check' => array('UINT', 0), - 'rule_connection' => array('UINT', 0), - 'rule_string' => array('VCHAR_UNI', ''), - 'rule_user_id' => array('UINT', 0), - 'rule_group_id' => array('UINT', 0), - 'rule_action' => array('UINT', 0), - 'rule_folder_id' => array('INT:11', 0), - ), - 'PRIMARY_KEY' => 'rule_id', - 'KEYS' => array( - 'user_id' => array('INDEX', 'user_id'), - ), - ); - - $schema_data['phpbb_privmsgs_to'] = array( - 'COLUMNS' => array( - 'msg_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'author_id' => array('UINT', 0), - 'pm_deleted' => array('BOOL', 0), - 'pm_new' => array('BOOL', 1), - 'pm_unread' => array('BOOL', 1), - 'pm_replied' => array('BOOL', 0), - 'pm_marked' => array('BOOL', 0), - 'pm_forwarded' => array('BOOL', 0), - 'folder_id' => array('INT:11', 0), - ), - 'KEYS' => array( - 'msg_id' => array('INDEX', 'msg_id'), - 'author_id' => array('INDEX', 'author_id'), - 'usr_flder_id' => array('INDEX', array('user_id', 'folder_id')), - ), - ); - - $schema_data['phpbb_profile_fields'] = array( - 'COLUMNS' => array( - 'field_id' => array('UINT', NULL, 'auto_increment'), - 'field_name' => array('VCHAR_UNI', ''), - 'field_type' => array('TINT:4', 0), - 'field_ident' => array('VCHAR:20', ''), - 'field_length' => array('VCHAR:20', ''), - 'field_minlen' => array('VCHAR', ''), - 'field_maxlen' => array('VCHAR', ''), - 'field_novalue' => array('VCHAR_UNI', ''), - 'field_default_value' => array('VCHAR_UNI', ''), - 'field_validation' => array('VCHAR_UNI:20', ''), - 'field_required' => array('BOOL', 0), - 'field_show_novalue' => array('BOOL', 0), - 'field_show_on_reg' => array('BOOL', 0), - 'field_show_on_vt' => array('BOOL', 0), - 'field_show_profile' => array('BOOL', 0), - 'field_hide' => array('BOOL', 0), - 'field_no_view' => array('BOOL', 0), - 'field_active' => array('BOOL', 0), - 'field_order' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'field_id', - 'KEYS' => array( - 'fld_type' => array('INDEX', 'field_type'), - 'fld_ordr' => array('INDEX', 'field_order'), - ), - ); - - $schema_data['phpbb_profile_fields_data'] = array( - 'COLUMNS' => array( - 'user_id' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'user_id', - ); - - $schema_data['phpbb_profile_fields_lang'] = array( - 'COLUMNS' => array( - 'field_id' => array('UINT', 0), - 'lang_id' => array('UINT', 0), - 'option_id' => array('UINT', 0), - 'field_type' => array('TINT:4', 0), - 'lang_value' => array('VCHAR_UNI', ''), - ), - 'PRIMARY_KEY' => array('field_id', 'lang_id', 'option_id'), - ); - - $schema_data['phpbb_profile_lang'] = array( - 'COLUMNS' => array( - 'field_id' => array('UINT', 0), - 'lang_id' => array('UINT', 0), - 'lang_name' => array('VCHAR_UNI', ''), - 'lang_explain' => array('TEXT_UNI', ''), - 'lang_default_value' => array('VCHAR_UNI', ''), - ), - 'PRIMARY_KEY' => array('field_id', 'lang_id'), - ); - - $schema_data['phpbb_ranks'] = array( - 'COLUMNS' => array( - 'rank_id' => array('UINT', NULL, 'auto_increment'), - 'rank_title' => array('VCHAR_UNI', ''), - 'rank_min' => array('UINT', 0), - 'rank_special' => array('BOOL', 0), - 'rank_image' => array('VCHAR', ''), - ), - 'PRIMARY_KEY' => 'rank_id', - ); - - $schema_data['phpbb_reports'] = array( - 'COLUMNS' => array( - 'report_id' => array('UINT', NULL, 'auto_increment'), - 'reason_id' => array('USINT', 0), - 'post_id' => array('UINT', 0), - 'pm_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'user_notify' => array('BOOL', 0), - 'report_closed' => array('BOOL', 0), - 'report_time' => array('TIMESTAMP', 0), - 'report_text' => array('MTEXT_UNI', ''), - ), - 'PRIMARY_KEY' => 'report_id', - 'KEYS' => array( - 'post_id' => array('INDEX', 'post_id'), - 'pm_id' => array('INDEX', 'pm_id'), - ), - ); - - $schema_data['phpbb_reports_reasons'] = array( - 'COLUMNS' => array( - 'reason_id' => array('USINT', NULL, 'auto_increment'), - 'reason_title' => array('VCHAR_UNI', ''), - 'reason_description' => array('MTEXT_UNI', ''), - 'reason_order' => array('USINT', 0), - ), - 'PRIMARY_KEY' => 'reason_id', - ); - - $schema_data['phpbb_search_results'] = array( - 'COLUMNS' => array( - 'search_key' => array('VCHAR:32', ''), - 'search_time' => array('TIMESTAMP', 0), - 'search_keywords' => array('MTEXT_UNI', ''), - 'search_authors' => array('MTEXT', ''), - ), - 'PRIMARY_KEY' => 'search_key', - ); - - $schema_data['phpbb_search_wordlist'] = array( - 'COLUMNS' => array( - 'word_id' => array('UINT', NULL, 'auto_increment'), - 'word_text' => array('VCHAR_UNI', ''), - 'word_common' => array('BOOL', 0), - 'word_count' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'word_id', - 'KEYS' => array( - 'wrd_txt' => array('UNIQUE', 'word_text'), - 'wrd_cnt' => array('INDEX', 'word_count'), - ), - ); - - $schema_data['phpbb_search_wordmatch'] = array( - 'COLUMNS' => array( - 'post_id' => array('UINT', 0), - 'word_id' => array('UINT', 0), - 'title_match' => array('BOOL', 0), - ), - 'KEYS' => array( - 'unq_mtch' => array('UNIQUE', array('word_id', 'post_id', 'title_match')), - 'word_id' => array('INDEX', 'word_id'), - 'post_id' => array('INDEX', 'post_id'), - ), - ); - - $schema_data['phpbb_sessions'] = array( - 'COLUMNS' => array( - 'session_id' => array('CHAR:32', ''), - 'session_user_id' => array('UINT', 0), - 'session_forum_id' => array('UINT', 0), - 'session_last_visit' => array('TIMESTAMP', 0), - 'session_start' => array('TIMESTAMP', 0), - 'session_time' => array('TIMESTAMP', 0), - 'session_ip' => array('VCHAR:40', ''), - 'session_browser' => array('VCHAR:150', ''), - 'session_forwarded_for' => array('VCHAR:255', ''), - 'session_page' => array('VCHAR_UNI', ''), - 'session_viewonline' => array('BOOL', 1), - 'session_autologin' => array('BOOL', 0), - 'session_admin' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => 'session_id', - 'KEYS' => array( - 'session_time' => array('INDEX', 'session_time'), - 'session_user_id' => array('INDEX', 'session_user_id'), - 'session_fid' => array('INDEX', 'session_forum_id'), - ), - ); - - $schema_data['phpbb_sessions_keys'] = array( - 'COLUMNS' => array( - 'key_id' => array('CHAR:32', ''), - 'user_id' => array('UINT', 0), - 'last_ip' => array('VCHAR:40', ''), - 'last_login' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => array('key_id', 'user_id'), - 'KEYS' => array( - 'last_login' => array('INDEX', 'last_login'), - ), - ); - - $schema_data['phpbb_sitelist'] = array( - 'COLUMNS' => array( - 'site_id' => array('UINT', NULL, 'auto_increment'), - 'site_ip' => array('VCHAR:40', ''), - 'site_hostname' => array('VCHAR', ''), - 'ip_exclude' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => 'site_id', - ); - - $schema_data['phpbb_smilies'] = array( - 'COLUMNS' => array( - 'smiley_id' => array('UINT', NULL, 'auto_increment'), - // We may want to set 'code' to VCHAR:50 or check if unicode support is possible... at the moment only ASCII characters are allowed. - 'code' => array('VCHAR_UNI:50', ''), - 'emotion' => array('VCHAR_UNI:50', ''), - 'smiley_url' => array('VCHAR:50', ''), - 'smiley_width' => array('USINT', 0), - 'smiley_height' => array('USINT', 0), - 'smiley_order' => array('UINT', 0), - 'display_on_posting'=> array('BOOL', 1), - ), - 'PRIMARY_KEY' => 'smiley_id', - 'KEYS' => array( - 'display_on_post' => array('INDEX', 'display_on_posting'), - ), - ); - - $schema_data['phpbb_styles'] = array( - 'COLUMNS' => array( - 'style_id' => array('UINT', NULL, 'auto_increment'), - 'style_name' => array('VCHAR_UNI:255', ''), - 'style_copyright' => array('VCHAR_UNI', ''), - 'style_active' => array('BOOL', 1), - 'style_path' => array('VCHAR:100', ''), - 'bbcode_bitfield' => array('VCHAR:255', 'kNg='), - 'style_parent_id' => array('UINT:4', 0), - 'style_parent_tree' => array('TEXT', ''), - ), - 'PRIMARY_KEY' => 'style_id', - 'KEYS' => array( - 'style_name' => array('UNIQUE', 'style_name'), - ), - ); - - $schema_data['phpbb_topics'] = array( - 'COLUMNS' => array( - 'topic_id' => array('UINT', NULL, 'auto_increment'), - 'forum_id' => array('UINT', 0), - 'icon_id' => array('UINT', 0), - 'topic_attachment' => array('BOOL', 0), - 'topic_visibility' => array('TINT:3', 0), - 'topic_reported' => array('BOOL', 0), - 'topic_title' => array('STEXT_UNI', '', 'true_sort'), - 'topic_poster' => array('UINT', 0), - 'topic_time' => array('TIMESTAMP', 0), - 'topic_time_limit' => array('TIMESTAMP', 0), - 'topic_views' => array('UINT', 0), - 'topic_posts_approved' => array('UINT', 0), - 'topic_posts_unapproved' => array('UINT', 0), - 'topic_posts_softdeleted' => array('UINT', 0), - 'topic_status' => array('TINT:3', 0), - 'topic_type' => array('TINT:3', 0), - 'topic_first_post_id' => array('UINT', 0), - 'topic_first_poster_name' => array('VCHAR_UNI', ''), - 'topic_first_poster_colour' => array('VCHAR:6', ''), - 'topic_last_post_id' => array('UINT', 0), - 'topic_last_poster_id' => array('UINT', 0), - 'topic_last_poster_name' => array('VCHAR_UNI', ''), - 'topic_last_poster_colour' => array('VCHAR:6', ''), - 'topic_last_post_subject' => array('STEXT_UNI', ''), - 'topic_last_post_time' => array('TIMESTAMP', 0), - 'topic_last_view_time' => array('TIMESTAMP', 0), - 'topic_moved_id' => array('UINT', 0), - 'topic_bumped' => array('BOOL', 0), - 'topic_bumper' => array('UINT', 0), - 'poll_title' => array('STEXT_UNI', ''), - 'poll_start' => array('TIMESTAMP', 0), - 'poll_length' => array('TIMESTAMP', 0), - 'poll_max_options' => array('TINT:4', 1), - 'poll_last_vote' => array('TIMESTAMP', 0), - 'poll_vote_change' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => 'topic_id', - 'KEYS' => array( - 'forum_id' => array('INDEX', 'forum_id'), - 'forum_id_type' => array('INDEX', array('forum_id', 'topic_type')), - 'last_post_time' => array('INDEX', 'topic_last_post_time'), - 'topic_visibility' => array('INDEX', 'topic_visibility'), - 'forum_appr_last' => array('INDEX', array('forum_id', 'topic_visibility', 'topic_last_post_id')), - 'fid_time_moved' => array('INDEX', array('forum_id', 'topic_last_post_time', 'topic_moved_id')), - ), - ); - - $schema_data['phpbb_topics_track'] = array( - 'COLUMNS' => array( - 'user_id' => array('UINT', 0), - 'topic_id' => array('UINT', 0), - 'forum_id' => array('UINT', 0), - 'mark_time' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => array('user_id', 'topic_id'), - 'KEYS' => array( - 'topic_id' => array('INDEX', 'topic_id'), - 'forum_id' => array('INDEX', 'forum_id'), - ), - ); - - $schema_data['phpbb_topics_posted'] = array( - 'COLUMNS' => array( - 'user_id' => array('UINT', 0), - 'topic_id' => array('UINT', 0), - 'topic_posted' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => array('user_id', 'topic_id'), - ); - - $schema_data['phpbb_topics_watch'] = array( - 'COLUMNS' => array( - 'topic_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'notify_status' => array('BOOL', 0), - ), - 'KEYS' => array( - 'topic_id' => array('INDEX', 'topic_id'), - 'user_id' => array('INDEX', 'user_id'), - 'notify_stat' => array('INDEX', 'notify_status'), - ), - ); - - $schema_data['phpbb_user_group'] = array( - 'COLUMNS' => array( - 'group_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'group_leader' => array('BOOL', 0), - 'user_pending' => array('BOOL', 1), - ), - 'KEYS' => array( - 'group_id' => array('INDEX', 'group_id'), - 'user_id' => array('INDEX', 'user_id'), - 'group_leader' => array('INDEX', 'group_leader'), - ), - ); - - $schema_data['phpbb_users'] = array( - 'COLUMNS' => array( - 'user_id' => array('UINT', NULL, 'auto_increment'), - 'user_type' => array('TINT:2', 0), - 'group_id' => array('UINT', 3), - 'user_permissions' => array('MTEXT', ''), - 'user_perm_from' => array('UINT', 0), - 'user_ip' => array('VCHAR:40', ''), - 'user_regdate' => array('TIMESTAMP', 0), - 'username' => array('VCHAR_CI', ''), - 'username_clean' => array('VCHAR_CI', ''), - 'user_password' => array('VCHAR_UNI:40', ''), - 'user_passchg' => array('TIMESTAMP', 0), - 'user_pass_convert' => array('BOOL', 0), - 'user_email' => array('VCHAR_UNI:100', ''), - 'user_email_hash' => array('BINT', 0), - 'user_birthday' => array('VCHAR:10', ''), - 'user_lastvisit' => array('TIMESTAMP', 0), - 'user_lastmark' => array('TIMESTAMP', 0), - 'user_lastpost_time' => array('TIMESTAMP', 0), - 'user_lastpage' => array('VCHAR_UNI:200', ''), - 'user_last_confirm_key' => array('VCHAR:10', ''), - 'user_last_search' => array('TIMESTAMP', 0), - 'user_warnings' => array('TINT:4', 0), - 'user_last_warning' => array('TIMESTAMP', 0), - 'user_login_attempts' => array('TINT:4', 0), - 'user_inactive_reason' => array('TINT:2', 0), - 'user_inactive_time' => array('TIMESTAMP', 0), - 'user_posts' => array('UINT', 0), - 'user_lang' => array('VCHAR:30', ''), - 'user_timezone' => array('VCHAR:100', 'UTC'), - 'user_dateformat' => array('VCHAR_UNI:30', 'd M Y H:i'), - 'user_style' => array('UINT', 0), - 'user_rank' => array('UINT', 0), - 'user_colour' => array('VCHAR:6', ''), - 'user_new_privmsg' => array('INT:4', 0), - 'user_unread_privmsg' => array('INT:4', 0), - 'user_last_privmsg' => array('TIMESTAMP', 0), - 'user_message_rules' => array('BOOL', 0), - 'user_full_folder' => array('INT:11', -3), - 'user_emailtime' => array('TIMESTAMP', 0), - 'user_topic_show_days' => array('USINT', 0), - 'user_topic_sortby_type' => array('VCHAR:1', 't'), - 'user_topic_sortby_dir' => array('VCHAR:1', 'd'), - 'user_post_show_days' => array('USINT', 0), - 'user_post_sortby_type' => array('VCHAR:1', 't'), - 'user_post_sortby_dir' => array('VCHAR:1', 'a'), - 'user_notify' => array('BOOL', 0), - 'user_notify_pm' => array('BOOL', 1), - 'user_notify_type' => array('TINT:4', 0), - 'user_allow_pm' => array('BOOL', 1), - 'user_allow_viewonline' => array('BOOL', 1), - 'user_allow_viewemail' => array('BOOL', 1), - 'user_allow_massemail' => array('BOOL', 1), - 'user_options' => array('UINT:11', 230271), - 'user_avatar' => array('VCHAR', ''), - 'user_avatar_type' => array('TINT:2', 0), - 'user_avatar_width' => array('USINT', 0), - 'user_avatar_height' => array('USINT', 0), - 'user_sig' => array('MTEXT_UNI', ''), - 'user_sig_bbcode_uid' => array('VCHAR:8', ''), - 'user_sig_bbcode_bitfield' => array('VCHAR:255', ''), - 'user_from' => array('VCHAR_UNI:100', ''), - 'user_icq' => array('VCHAR:15', ''), - 'user_aim' => array('VCHAR_UNI', ''), - 'user_yim' => array('VCHAR_UNI', ''), - 'user_msnm' => array('VCHAR_UNI', ''), - 'user_jabber' => array('VCHAR_UNI', ''), - 'user_website' => array('VCHAR_UNI:200', ''), - 'user_occ' => array('TEXT_UNI', ''), - 'user_interests' => array('TEXT_UNI', ''), - 'user_actkey' => array('VCHAR:32', ''), - 'user_newpasswd' => array('VCHAR_UNI:40', ''), - 'user_form_salt' => array('VCHAR_UNI:32', ''), - 'user_new' => array('BOOL', 1), - 'user_reminded' => array('TINT:4', 0), - 'user_reminded_time' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => 'user_id', - 'KEYS' => array( - 'user_birthday' => array('INDEX', 'user_birthday'), - 'user_email_hash' => array('INDEX', 'user_email_hash'), - 'user_type' => array('INDEX', 'user_type'), - 'username_clean' => array('UNIQUE', 'username_clean'), - ), - ); - - $schema_data['phpbb_warnings'] = array( - 'COLUMNS' => array( - 'warning_id' => array('UINT', NULL, 'auto_increment'), - 'user_id' => array('UINT', 0), - 'post_id' => array('UINT', 0), - 'log_id' => array('UINT', 0), - 'warning_time' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => 'warning_id', - ); - - $schema_data['phpbb_words'] = array( - 'COLUMNS' => array( - 'word_id' => array('UINT', NULL, 'auto_increment'), - 'word' => array('VCHAR_UNI', ''), - 'replacement' => array('VCHAR_UNI', ''), - ), - 'PRIMARY_KEY' => 'word_id', - ); - - $schema_data['phpbb_zebra'] = array( - 'COLUMNS' => array( - 'user_id' => array('UINT', 0), - 'zebra_id' => array('UINT', 0), - 'friend' => array('BOOL', 0), - 'foe' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => array('user_id', 'zebra_id'), - ); - - return $schema_data; -} diff --git a/phpBB/phpbb/db/schema_data.php b/phpBB/phpbb/db/schema_data.php new file mode 100644 index 0000000000..9940a9380f --- /dev/null +++ b/phpBB/phpbb/db/schema_data.php @@ -0,0 +1,1194 @@ + {TABLE_DATA}) +* {TABLE_DATA}: +* COLUMNS = array({column_name} = array({column_type}, {default}, {auto_increment})) +* PRIMARY_KEY = {column_name(s)} +* KEYS = array({key_name} = array({key_type}, {column_name(s)})), +* +* Column Types: +* INT:x => SIGNED int(x) +* BINT => BIGINT +* UINT => mediumint(8) UNSIGNED +* UINT:x => int(x) UNSIGNED +* TINT:x => tinyint(x) +* USINT => smallint(4) UNSIGNED (for _order columns) +* BOOL => tinyint(1) UNSIGNED +* VCHAR => varchar(255) +* CHAR:x => char(x) +* XSTEXT_UNI => text for storing 100 characters (topic_title for example) +* STEXT_UNI => text for storing 255 characters (normal input field with a max of 255 single-byte chars) - same as VCHAR_UNI +* TEXT_UNI => text for storing 3000 characters (short text, descriptions, comments, etc.) +* MTEXT_UNI => mediumtext (post text, large text) +* VCHAR:x => varchar(x) +* TIMESTAMP => int(11) UNSIGNED +* DECIMAL => decimal number (5,2) +* DECIMAL: => decimal number (x,2) +* PDECIMAL => precision decimal number (6,3) +* PDECIMAL: => precision decimal number (x,3) +* VCHAR_UNI => varchar(255) BINARY +* VCHAR_CI => varchar_ci for postgresql, others VCHAR +*/ +$schema_data['phpbb_attachments'] = array( + 'COLUMNS' => array( + 'attach_id' => array('UINT', NULL, 'auto_increment'), + 'post_msg_id' => array('UINT', 0), + 'topic_id' => array('UINT', 0), + 'in_message' => array('BOOL', 0), + 'poster_id' => array('UINT', 0), + 'is_orphan' => array('BOOL', 1), + 'physical_filename' => array('VCHAR', ''), + 'real_filename' => array('VCHAR', ''), + 'download_count' => array('UINT', 0), + 'attach_comment' => array('TEXT_UNI', ''), + 'extension' => array('VCHAR:100', ''), + 'mimetype' => array('VCHAR:100', ''), + 'filesize' => array('UINT:20', 0), + 'filetime' => array('TIMESTAMP', 0), + 'thumbnail' => array('BOOL', 0), + ), + 'PRIMARY_KEY' => 'attach_id', + 'KEYS' => array( + 'filetime' => array('INDEX', 'filetime'), + 'post_msg_id' => array('INDEX', 'post_msg_id'), + 'topic_id' => array('INDEX', 'topic_id'), + 'poster_id' => array('INDEX', 'poster_id'), + 'is_orphan' => array('INDEX', 'is_orphan'), + ), +); + +$schema_data['phpbb_acl_groups'] = array( + 'COLUMNS' => array( + 'group_id' => array('UINT', 0), + 'forum_id' => array('UINT', 0), + 'auth_option_id' => array('UINT', 0), + 'auth_role_id' => array('UINT', 0), + 'auth_setting' => array('TINT:2', 0), + ), + 'KEYS' => array( + 'group_id' => array('INDEX', 'group_id'), + 'auth_opt_id' => array('INDEX', 'auth_option_id'), + 'auth_role_id' => array('INDEX', 'auth_role_id'), + ), +); + +$schema_data['phpbb_acl_options'] = array( + 'COLUMNS' => array( + 'auth_option_id' => array('UINT', NULL, 'auto_increment'), + 'auth_option' => array('VCHAR:50', ''), + 'is_global' => array('BOOL', 0), + 'is_local' => array('BOOL', 0), + 'founder_only' => array('BOOL', 0), + ), + 'PRIMARY_KEY' => 'auth_option_id', + 'KEYS' => array( + 'auth_option' => array('UNIQUE', 'auth_option'), + ), +); + +$schema_data['phpbb_acl_roles'] = array( + 'COLUMNS' => array( + 'role_id' => array('UINT', NULL, 'auto_increment'), + 'role_name' => array('VCHAR_UNI', ''), + 'role_description' => array('TEXT_UNI', ''), + 'role_type' => array('VCHAR:10', ''), + 'role_order' => array('USINT', 0), + ), + 'PRIMARY_KEY' => 'role_id', + 'KEYS' => array( + 'role_type' => array('INDEX', 'role_type'), + 'role_order' => array('INDEX', 'role_order'), + ), +); + +$schema_data['phpbb_acl_roles_data'] = array( + 'COLUMNS' => array( + 'role_id' => array('UINT', 0), + 'auth_option_id' => array('UINT', 0), + 'auth_setting' => array('TINT:2', 0), + ), + 'PRIMARY_KEY' => array('role_id', 'auth_option_id'), + 'KEYS' => array( + 'ath_op_id' => array('INDEX', 'auth_option_id'), + ), +); + +$schema_data['phpbb_acl_users'] = array( + 'COLUMNS' => array( + 'user_id' => array('UINT', 0), + 'forum_id' => array('UINT', 0), + 'auth_option_id' => array('UINT', 0), + 'auth_role_id' => array('UINT', 0), + 'auth_setting' => array('TINT:2', 0), + ), + 'KEYS' => array( + 'user_id' => array('INDEX', 'user_id'), + 'auth_option_id' => array('INDEX', 'auth_option_id'), + 'auth_role_id' => array('INDEX', 'auth_role_id'), + ), +); + +$schema_data['phpbb_banlist'] = array( + 'COLUMNS' => array( + 'ban_id' => array('UINT', NULL, 'auto_increment'), + 'ban_userid' => array('UINT', 0), + 'ban_ip' => array('VCHAR:40', ''), + 'ban_email' => array('VCHAR_UNI:100', ''), + 'ban_start' => array('TIMESTAMP', 0), + 'ban_end' => array('TIMESTAMP', 0), + 'ban_exclude' => array('BOOL', 0), + 'ban_reason' => array('VCHAR_UNI', ''), + 'ban_give_reason' => array('VCHAR_UNI', ''), + ), + 'PRIMARY_KEY' => 'ban_id', + 'KEYS' => array( + 'ban_end' => array('INDEX', 'ban_end'), + 'ban_user' => array('INDEX', array('ban_userid', 'ban_exclude')), + 'ban_email' => array('INDEX', array('ban_email', 'ban_exclude')), + 'ban_ip' => array('INDEX', array('ban_ip', 'ban_exclude')), + ), +); + +$schema_data['phpbb_bbcodes'] = array( + 'COLUMNS' => array( + 'bbcode_id' => array('USINT', 0), + 'bbcode_tag' => array('VCHAR:16', ''), + 'bbcode_helpline' => array('VCHAR_UNI', ''), + 'display_on_posting' => array('BOOL', 0), + 'bbcode_match' => array('TEXT_UNI', ''), + 'bbcode_tpl' => array('MTEXT_UNI', ''), + 'first_pass_match' => array('MTEXT_UNI', ''), + 'first_pass_replace' => array('MTEXT_UNI', ''), + 'second_pass_match' => array('MTEXT_UNI', ''), + 'second_pass_replace' => array('MTEXT_UNI', ''), + ), + 'PRIMARY_KEY' => 'bbcode_id', + 'KEYS' => array( + 'display_on_post' => array('INDEX', 'display_on_posting'), + ), +); + +$schema_data['phpbb_bookmarks'] = array( + 'COLUMNS' => array( + 'topic_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + ), + 'PRIMARY_KEY' => array('topic_id', 'user_id'), +); + +$schema_data['phpbb_bots'] = array( + 'COLUMNS' => array( + 'bot_id' => array('UINT', NULL, 'auto_increment'), + 'bot_active' => array('BOOL', 1), + 'bot_name' => array('STEXT_UNI', ''), + 'user_id' => array('UINT', 0), + 'bot_agent' => array('VCHAR', ''), + 'bot_ip' => array('VCHAR', ''), + ), + 'PRIMARY_KEY' => 'bot_id', + 'KEYS' => array( + 'bot_active' => array('INDEX', 'bot_active'), + ), +); + +$schema_data['phpbb_config'] = array( + 'COLUMNS' => array( + 'config_name' => array('VCHAR', ''), + 'config_value' => array('VCHAR_UNI', ''), + 'is_dynamic' => array('BOOL', 0), + ), + 'PRIMARY_KEY' => 'config_name', + 'KEYS' => array( + 'is_dynamic' => array('INDEX', 'is_dynamic'), + ), +); + +$schema_data['phpbb_config_text'] = array( + 'COLUMNS' => array( + 'config_name' => array('VCHAR', ''), + 'config_value' => array('MTEXT', ''), + ), + 'PRIMARY_KEY' => 'config_name', +); + +$schema_data['phpbb_confirm'] = array( + 'COLUMNS' => array( + 'confirm_id' => array('CHAR:32', ''), + 'session_id' => array('CHAR:32', ''), + 'confirm_type' => array('TINT:3', 0), + 'code' => array('VCHAR:8', ''), + 'seed' => array('UINT:10', 0), + 'attempts' => array('UINT', 0), + ), + 'PRIMARY_KEY' => array('session_id', 'confirm_id'), + 'KEYS' => array( + 'confirm_type' => array('INDEX', 'confirm_type'), + ), +); + +$schema_data['phpbb_disallow'] = array( + 'COLUMNS' => array( + 'disallow_id' => array('UINT', NULL, 'auto_increment'), + 'disallow_username' => array('VCHAR_UNI:255', ''), + ), + 'PRIMARY_KEY' => 'disallow_id', +); + +$schema_data['phpbb_drafts'] = array( + 'COLUMNS' => array( + 'draft_id' => array('UINT', NULL, 'auto_increment'), + 'user_id' => array('UINT', 0), + 'topic_id' => array('UINT', 0), + 'forum_id' => array('UINT', 0), + 'save_time' => array('TIMESTAMP', 0), + 'draft_subject' => array('STEXT_UNI', ''), + 'draft_message' => array('MTEXT_UNI', ''), + ), + 'PRIMARY_KEY' => 'draft_id', + 'KEYS' => array( + 'save_time' => array('INDEX', 'save_time'), + ), +); + +$schema_data['phpbb_ext'] = array( + 'COLUMNS' => array( + 'ext_name' => array('VCHAR', ''), + 'ext_active' => array('BOOL', 0), + 'ext_state' => array('TEXT', ''), + ), + 'KEYS' => array( + 'ext_name' => array('UNIQUE', 'ext_name'), + ), +); + +$schema_data['phpbb_extensions'] = array( + 'COLUMNS' => array( + 'extension_id' => array('UINT', NULL, 'auto_increment'), + 'group_id' => array('UINT', 0), + 'extension' => array('VCHAR:100', ''), + ), + 'PRIMARY_KEY' => 'extension_id', +); + +$schema_data['phpbb_extension_groups'] = array( + 'COLUMNS' => array( + 'group_id' => array('UINT', NULL, 'auto_increment'), + 'group_name' => array('VCHAR_UNI', ''), + 'cat_id' => array('TINT:2', 0), + 'allow_group' => array('BOOL', 0), + 'download_mode' => array('BOOL', 1), + 'upload_icon' => array('VCHAR', ''), + 'max_filesize' => array('UINT:20', 0), + 'allowed_forums' => array('TEXT', ''), + 'allow_in_pm' => array('BOOL', 0), + ), + 'PRIMARY_KEY' => 'group_id', +); + +$schema_data['phpbb_forums'] = array( + 'COLUMNS' => array( + 'forum_id' => array('UINT', NULL, 'auto_increment'), + 'parent_id' => array('UINT', 0), + 'left_id' => array('UINT', 0), + 'right_id' => array('UINT', 0), + 'forum_parents' => array('MTEXT', ''), + 'forum_name' => array('STEXT_UNI', ''), + 'forum_desc' => array('TEXT_UNI', ''), + 'forum_desc_bitfield' => array('VCHAR:255', ''), + 'forum_desc_options' => array('UINT:11', 7), + 'forum_desc_uid' => array('VCHAR:8', ''), + 'forum_link' => array('VCHAR_UNI', ''), + 'forum_password' => array('VCHAR_UNI:40', ''), + 'forum_style' => array('UINT', 0), + 'forum_image' => array('VCHAR', ''), + 'forum_rules' => array('TEXT_UNI', ''), + 'forum_rules_link' => array('VCHAR_UNI', ''), + 'forum_rules_bitfield' => array('VCHAR:255', ''), + 'forum_rules_options' => array('UINT:11', 7), + 'forum_rules_uid' => array('VCHAR:8', ''), + 'forum_topics_per_page' => array('TINT:4', 0), + 'forum_type' => array('TINT:4', 0), + 'forum_status' => array('TINT:4', 0), + 'forum_posts_approved' => array('UINT', 0), + 'forum_posts_unapproved' => array('UINT', 0), + 'forum_posts_softdeleted' => array('UINT', 0), + 'forum_topics_approved' => array('UINT', 0), + 'forum_topics_unapproved' => array('UINT', 0), + 'forum_topics_softdeleted' => array('UINT', 0), + 'forum_last_post_id' => array('UINT', 0), + 'forum_last_poster_id' => array('UINT', 0), + 'forum_last_post_subject' => array('STEXT_UNI', ''), + 'forum_last_post_time' => array('TIMESTAMP', 0), + 'forum_last_poster_name'=> array('VCHAR_UNI', ''), + 'forum_last_poster_colour'=> array('VCHAR:6', ''), + 'forum_flags' => array('TINT:4', 32), + 'forum_options' => array('UINT:20', 0), + 'display_subforum_list' => array('BOOL', 1), + 'display_on_index' => array('BOOL', 1), + 'enable_indexing' => array('BOOL', 1), + 'enable_icons' => array('BOOL', 1), + 'enable_prune' => array('BOOL', 0), + 'prune_next' => array('TIMESTAMP', 0), + 'prune_days' => array('UINT', 0), + 'prune_viewed' => array('UINT', 0), + 'prune_freq' => array('UINT', 0), + ), + 'PRIMARY_KEY' => 'forum_id', + 'KEYS' => array( + 'left_right_id' => array('INDEX', array('left_id', 'right_id')), + 'forum_lastpost_id' => array('INDEX', 'forum_last_post_id'), + ), +); + +$schema_data['phpbb_forums_access'] = array( + 'COLUMNS' => array( + 'forum_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'session_id' => array('CHAR:32', ''), + ), + 'PRIMARY_KEY' => array('forum_id', 'user_id', 'session_id'), +); + +$schema_data['phpbb_forums_track'] = array( + 'COLUMNS' => array( + 'user_id' => array('UINT', 0), + 'forum_id' => array('UINT', 0), + 'mark_time' => array('TIMESTAMP', 0), + ), + 'PRIMARY_KEY' => array('user_id', 'forum_id'), +); + +$schema_data['phpbb_forums_watch'] = array( + 'COLUMNS' => array( + 'forum_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'notify_status' => array('BOOL', 0), + ), + 'KEYS' => array( + 'forum_id' => array('INDEX', 'forum_id'), + 'user_id' => array('INDEX', 'user_id'), + 'notify_stat' => array('INDEX', 'notify_status'), + ), +); + +$schema_data['phpbb_groups'] = array( + 'COLUMNS' => array( + 'group_id' => array('UINT', NULL, 'auto_increment'), + 'group_type' => array('TINT:4', 1), + 'group_founder_manage' => array('BOOL', 0), + 'group_skip_auth' => array('BOOL', 0), + 'group_name' => array('VCHAR_CI', ''), + 'group_desc' => array('TEXT_UNI', ''), + 'group_desc_bitfield' => array('VCHAR:255', ''), + 'group_desc_options' => array('UINT:11', 7), + 'group_desc_uid' => array('VCHAR:8', ''), + 'group_display' => array('BOOL', 0), + 'group_avatar' => array('VCHAR', ''), + 'group_avatar_type' => array('VCHAR:255', ''), + 'group_avatar_width' => array('USINT', 0), + 'group_avatar_height' => array('USINT', 0), + 'group_rank' => array('UINT', 0), + 'group_colour' => array('VCHAR:6', ''), + 'group_sig_chars' => array('UINT', 0), + 'group_receive_pm' => array('BOOL', 0), + 'group_message_limit' => array('UINT', 0), + 'group_max_recipients' => array('UINT', 0), + 'group_legend' => array('UINT', 0), + ), + 'PRIMARY_KEY' => 'group_id', + 'KEYS' => array( + 'group_legend_name' => array('INDEX', array('group_legend', 'group_name')), + ), +); + +$schema_data['phpbb_icons'] = array( + 'COLUMNS' => array( + 'icons_id' => array('UINT', NULL, 'auto_increment'), + 'icons_url' => array('VCHAR', ''), + 'icons_width' => array('TINT:4', 0), + 'icons_height' => array('TINT:4', 0), + 'icons_order' => array('UINT', 0), + 'display_on_posting' => array('BOOL', 1), + ), + 'PRIMARY_KEY' => 'icons_id', + 'KEYS' => array( + 'display_on_posting' => array('INDEX', 'display_on_posting'), + ), +); + +$schema_data['phpbb_lang'] = array( + 'COLUMNS' => array( + 'lang_id' => array('TINT:4', NULL, 'auto_increment'), + 'lang_iso' => array('VCHAR:30', ''), + 'lang_dir' => array('VCHAR:30', ''), + 'lang_english_name' => array('VCHAR_UNI:100', ''), + 'lang_local_name' => array('VCHAR_UNI:255', ''), + 'lang_author' => array('VCHAR_UNI:255', ''), + ), + 'PRIMARY_KEY' => 'lang_id', + 'KEYS' => array( + 'lang_iso' => array('INDEX', 'lang_iso'), + ), +); + +$schema_data['phpbb_log'] = array( + 'COLUMNS' => array( + 'log_id' => array('UINT', NULL, 'auto_increment'), + 'log_type' => array('TINT:4', 0), + 'user_id' => array('UINT', 0), + 'forum_id' => array('UINT', 0), + 'topic_id' => array('UINT', 0), + 'reportee_id' => array('UINT', 0), + 'log_ip' => array('VCHAR:40', ''), + 'log_time' => array('TIMESTAMP', 0), + 'log_operation' => array('TEXT_UNI', ''), + 'log_data' => array('MTEXT_UNI', ''), + ), + 'PRIMARY_KEY' => 'log_id', + 'KEYS' => array( + 'log_type' => array('INDEX', 'log_type'), + 'log_time' => array('INDEX', 'log_time'), + 'forum_id' => array('INDEX', 'forum_id'), + 'topic_id' => array('INDEX', 'topic_id'), + 'reportee_id' => array('INDEX', 'reportee_id'), + 'user_id' => array('INDEX', 'user_id'), + ), +); + +$schema_data['phpbb_login_attempts'] = array( + 'COLUMNS' => array( + 'attempt_ip' => array('VCHAR:40', ''), + 'attempt_browser' => array('VCHAR:150', ''), + 'attempt_forwarded_for' => array('VCHAR:255', ''), + 'attempt_time' => array('TIMESTAMP', 0), + 'user_id' => array('UINT', 0), + 'username' => array('VCHAR_UNI:255', 0), + 'username_clean' => array('VCHAR_CI', 0), + ), + 'KEYS' => array( + 'att_ip' => array('INDEX', array('attempt_ip', 'attempt_time')), + 'att_for' => array('INDEX', array('attempt_forwarded_for', 'attempt_time')), + 'att_time' => array('INDEX', array('attempt_time')), + 'user_id' => array('INDEX', 'user_id'), + ), +); + +$schema_data['phpbb_moderator_cache'] = array( + 'COLUMNS' => array( + 'forum_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'username' => array('VCHAR_UNI:255', ''), + 'group_id' => array('UINT', 0), + 'group_name' => array('VCHAR_UNI', ''), + 'display_on_index' => array('BOOL', 1), + ), + 'KEYS' => array( + 'disp_idx' => array('INDEX', 'display_on_index'), + 'forum_id' => array('INDEX', 'forum_id'), + ), +); + +$schema_data['phpbb_migrations'] = array( + 'COLUMNS' => array( + 'migration_name' => array('VCHAR', ''), + 'migration_depends_on' => array('TEXT', ''), + 'migration_schema_done' => array('BOOL', 0), + 'migration_data_done' => array('BOOL', 0), + 'migration_data_state' => array('TEXT', ''), + 'migration_start_time' => array('TIMESTAMP', 0), + 'migration_end_time' => array('TIMESTAMP', 0), + ), + 'PRIMARY_KEY' => 'migration_name', +); + +$schema_data['phpbb_modules'] = array( + 'COLUMNS' => array( + 'module_id' => array('UINT', NULL, 'auto_increment'), + 'module_enabled' => array('BOOL', 1), + 'module_display' => array('BOOL', 1), + 'module_basename' => array('VCHAR', ''), + 'module_class' => array('VCHAR:10', ''), + 'parent_id' => array('UINT', 0), + 'left_id' => array('UINT', 0), + 'right_id' => array('UINT', 0), + 'module_langname' => array('VCHAR', ''), + 'module_mode' => array('VCHAR', ''), + 'module_auth' => array('VCHAR', ''), + ), + 'PRIMARY_KEY' => 'module_id', + 'KEYS' => array( + 'left_right_id' => array('INDEX', array('left_id', 'right_id')), + 'module_enabled' => array('INDEX', 'module_enabled'), + 'class_left_id' => array('INDEX', array('module_class', 'left_id')), + ), +); + +$schema_data['phpbb_notification_types'] = array( + 'COLUMNS' => array( + 'notification_type_id' => array('USINT', NULL, 'auto_increment'), + 'notification_type_name' => array('VCHAR:255', ''), + 'notification_type_enabled' => array('BOOL', 1), + ), + 'PRIMARY_KEY' => array('notification_type_id'), + 'KEYS' => array( + 'type' => array('UNIQUE', array('notification_type_name')), + ), +); + +$schema_data['phpbb_notifications'] = array( + 'COLUMNS' => array( + 'notification_id' => array('UINT:10', NULL, 'auto_increment'), + 'notification_type_id' => array('USINT', 0), + 'item_id' => array('UINT', 0), + 'item_parent_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'notification_read' => array('BOOL', 0), + 'notification_time' => array('TIMESTAMP', 1), + 'notification_data' => array('TEXT_UNI', ''), + ), + 'PRIMARY_KEY' => 'notification_id', + 'KEYS' => array( + 'item_ident' => array('INDEX', array('notification_type_id', 'item_id')), + 'user' => array('INDEX', array('user_id', 'notification_read')), + ), +); + +$schema_data['phpbb_poll_options'] = array( + 'COLUMNS' => array( + 'poll_option_id' => array('TINT:4', 0), + 'topic_id' => array('UINT', 0), + 'poll_option_text' => array('TEXT_UNI', ''), + 'poll_option_total' => array('UINT', 0), + ), + 'KEYS' => array( + 'poll_opt_id' => array('INDEX', 'poll_option_id'), + 'topic_id' => array('INDEX', 'topic_id'), + ), +); + +$schema_data['phpbb_poll_votes'] = array( + 'COLUMNS' => array( + 'topic_id' => array('UINT', 0), + 'poll_option_id' => array('TINT:4', 0), + 'vote_user_id' => array('UINT', 0), + 'vote_user_ip' => array('VCHAR:40', ''), + ), + 'KEYS' => array( + 'topic_id' => array('INDEX', 'topic_id'), + 'vote_user_id' => array('INDEX', 'vote_user_id'), + 'vote_user_ip' => array('INDEX', 'vote_user_ip'), + ), +); + +$schema_data['phpbb_posts'] = array( + 'COLUMNS' => array( + 'post_id' => array('UINT', NULL, 'auto_increment'), + 'topic_id' => array('UINT', 0), + 'forum_id' => array('UINT', 0), + 'poster_id' => array('UINT', 0), + 'icon_id' => array('UINT', 0), + 'poster_ip' => array('VCHAR:40', ''), + 'post_time' => array('TIMESTAMP', 0), + 'post_visibility' => array('TINT:3', 0), + 'post_reported' => array('BOOL', 0), + 'enable_bbcode' => array('BOOL', 1), + 'enable_smilies' => array('BOOL', 1), + 'enable_magic_url' => array('BOOL', 1), + 'enable_sig' => array('BOOL', 1), + 'post_username' => array('VCHAR_UNI:255', ''), + 'post_subject' => array('STEXT_UNI', '', 'true_sort'), + 'post_text' => array('MTEXT_UNI', ''), + 'post_checksum' => array('VCHAR:32', ''), + 'post_attachment' => array('BOOL', 0), + 'bbcode_bitfield' => array('VCHAR:255', ''), + 'bbcode_uid' => array('VCHAR:8', ''), + 'post_postcount' => array('BOOL', 1), + 'post_edit_time' => array('TIMESTAMP', 0), + 'post_edit_reason' => array('STEXT_UNI', ''), + 'post_edit_user' => array('UINT', 0), + 'post_edit_count' => array('USINT', 0), + 'post_edit_locked' => array('BOOL', 0), + 'post_delete_time' => array('TIMESTAMP', 0), + 'post_delete_reason' => array('STEXT_UNI', ''), + 'post_delete_user' => array('UINT', 0), + ), + 'PRIMARY_KEY' => 'post_id', + 'KEYS' => array( + 'forum_id' => array('INDEX', 'forum_id'), + 'topic_id' => array('INDEX', 'topic_id'), + 'poster_ip' => array('INDEX', 'poster_ip'), + 'poster_id' => array('INDEX', 'poster_id'), + 'post_visibility' => array('INDEX', 'post_visibility'), + 'post_username' => array('INDEX', 'post_username'), + 'tid_post_time' => array('INDEX', array('topic_id', 'post_time')), + ), +); + +$schema_data['phpbb_privmsgs'] = array( + 'COLUMNS' => array( + 'msg_id' => array('UINT', NULL, 'auto_increment'), + 'root_level' => array('UINT', 0), + 'author_id' => array('UINT', 0), + 'icon_id' => array('UINT', 0), + 'author_ip' => array('VCHAR:40', ''), + 'message_time' => array('TIMESTAMP', 0), + 'enable_bbcode' => array('BOOL', 1), + 'enable_smilies' => array('BOOL', 1), + 'enable_magic_url' => array('BOOL', 1), + 'enable_sig' => array('BOOL', 1), + 'message_subject' => array('STEXT_UNI', ''), + 'message_text' => array('MTEXT_UNI', ''), + 'message_edit_reason' => array('STEXT_UNI', ''), + 'message_edit_user' => array('UINT', 0), + 'message_attachment' => array('BOOL', 0), + 'bbcode_bitfield' => array('VCHAR:255', ''), + 'bbcode_uid' => array('VCHAR:8', ''), + 'message_edit_time' => array('TIMESTAMP', 0), + 'message_edit_count' => array('USINT', 0), + 'to_address' => array('TEXT_UNI', ''), + 'bcc_address' => array('TEXT_UNI', ''), + 'message_reported' => array('BOOL', 0), + ), + 'PRIMARY_KEY' => 'msg_id', + 'KEYS' => array( + 'author_ip' => array('INDEX', 'author_ip'), + 'message_time' => array('INDEX', 'message_time'), + 'author_id' => array('INDEX', 'author_id'), + 'root_level' => array('INDEX', 'root_level'), + ), +); + +$schema_data['phpbb_privmsgs_folder'] = array( + 'COLUMNS' => array( + 'folder_id' => array('UINT', NULL, 'auto_increment'), + 'user_id' => array('UINT', 0), + 'folder_name' => array('VCHAR_UNI', ''), + 'pm_count' => array('UINT', 0), + ), + 'PRIMARY_KEY' => 'folder_id', + 'KEYS' => array( + 'user_id' => array('INDEX', 'user_id'), + ), +); + +$schema_data['phpbb_privmsgs_rules'] = array( + 'COLUMNS' => array( + 'rule_id' => array('UINT', NULL, 'auto_increment'), + 'user_id' => array('UINT', 0), + 'rule_check' => array('UINT', 0), + 'rule_connection' => array('UINT', 0), + 'rule_string' => array('VCHAR_UNI', ''), + 'rule_user_id' => array('UINT', 0), + 'rule_group_id' => array('UINT', 0), + 'rule_action' => array('UINT', 0), + 'rule_folder_id' => array('INT:11', 0), + ), + 'PRIMARY_KEY' => 'rule_id', + 'KEYS' => array( + 'user_id' => array('INDEX', 'user_id'), + ), +); + +$schema_data['phpbb_privmsgs_to'] = array( + 'COLUMNS' => array( + 'msg_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'author_id' => array('UINT', 0), + 'pm_deleted' => array('BOOL', 0), + 'pm_new' => array('BOOL', 1), + 'pm_unread' => array('BOOL', 1), + 'pm_replied' => array('BOOL', 0), + 'pm_marked' => array('BOOL', 0), + 'pm_forwarded' => array('BOOL', 0), + 'folder_id' => array('INT:11', 0), + ), + 'KEYS' => array( + 'msg_id' => array('INDEX', 'msg_id'), + 'author_id' => array('INDEX', 'author_id'), + 'usr_flder_id' => array('INDEX', array('user_id', 'folder_id')), + ), +); + +$schema_data['phpbb_profile_fields'] = array( + 'COLUMNS' => array( + 'field_id' => array('UINT', NULL, 'auto_increment'), + 'field_name' => array('VCHAR_UNI', ''), + 'field_type' => array('TINT:4', 0), + 'field_ident' => array('VCHAR:20', ''), + 'field_length' => array('VCHAR:20', ''), + 'field_minlen' => array('VCHAR', ''), + 'field_maxlen' => array('VCHAR', ''), + 'field_novalue' => array('VCHAR_UNI', ''), + 'field_default_value' => array('VCHAR_UNI', ''), + 'field_validation' => array('VCHAR_UNI:20', ''), + 'field_required' => array('BOOL', 0), + 'field_show_novalue' => array('BOOL', 0), + 'field_show_on_reg' => array('BOOL', 0), + 'field_show_on_pm' => array('BOOL', 0), + 'field_show_on_vt' => array('BOOL', 0), + 'field_show_profile' => array('BOOL', 0), + 'field_hide' => array('BOOL', 0), + 'field_no_view' => array('BOOL', 0), + 'field_active' => array('BOOL', 0), + 'field_order' => array('UINT', 0), + ), + 'PRIMARY_KEY' => 'field_id', + 'KEYS' => array( + 'fld_type' => array('INDEX', 'field_type'), + 'fld_ordr' => array('INDEX', 'field_order'), + ), +); + +$schema_data['phpbb_profile_fields_data'] = array( + 'COLUMNS' => array( + 'user_id' => array('UINT', 0), + ), + 'PRIMARY_KEY' => 'user_id', +); + +$schema_data['phpbb_profile_fields_lang'] = array( + 'COLUMNS' => array( + 'field_id' => array('UINT', 0), + 'lang_id' => array('UINT', 0), + 'option_id' => array('UINT', 0), + 'field_type' => array('TINT:4', 0), + 'lang_value' => array('VCHAR_UNI', ''), + ), + 'PRIMARY_KEY' => array('field_id', 'lang_id', 'option_id'), +); + +$schema_data['phpbb_profile_lang'] = array( + 'COLUMNS' => array( + 'field_id' => array('UINT', 0), + 'lang_id' => array('UINT', 0), + 'lang_name' => array('VCHAR_UNI', ''), + 'lang_explain' => array('TEXT_UNI', ''), + 'lang_default_value' => array('VCHAR_UNI', ''), + ), + 'PRIMARY_KEY' => array('field_id', 'lang_id'), +); + +$schema_data['phpbb_ranks'] = array( + 'COLUMNS' => array( + 'rank_id' => array('UINT', NULL, 'auto_increment'), + 'rank_title' => array('VCHAR_UNI', ''), + 'rank_min' => array('UINT', 0), + 'rank_special' => array('BOOL', 0), + 'rank_image' => array('VCHAR', ''), + ), + 'PRIMARY_KEY' => 'rank_id', +); + +$schema_data['phpbb_reports'] = array( + 'COLUMNS' => array( + 'report_id' => array('UINT', NULL, 'auto_increment'), + 'reason_id' => array('USINT', 0), + 'post_id' => array('UINT', 0), + 'pm_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'user_notify' => array('BOOL', 0), + 'report_closed' => array('BOOL', 0), + 'report_time' => array('TIMESTAMP', 0), + 'report_text' => array('MTEXT_UNI', ''), + 'reported_post_text' => array('MTEXT_UNI', ''), + 'reported_post_uid' => array('VCHAR:8', ''), + 'reported_post_bitfield' => array('VCHAR:255', ''), + 'reported_post_enable_magic_url' => array('BOOL', 1), + 'reported_post_enable_smilies' => array('BOOL', 1), + 'reported_post_enable_bbcode' => array('BOOL', 1) + ), + 'PRIMARY_KEY' => 'report_id', + 'KEYS' => array( + 'post_id' => array('INDEX', 'post_id'), + 'pm_id' => array('INDEX', 'pm_id'), + ), +); + +$schema_data['phpbb_reports_reasons'] = array( + 'COLUMNS' => array( + 'reason_id' => array('USINT', NULL, 'auto_increment'), + 'reason_title' => array('VCHAR_UNI', ''), + 'reason_description' => array('MTEXT_UNI', ''), + 'reason_order' => array('USINT', 0), + ), + 'PRIMARY_KEY' => 'reason_id', +); + +$schema_data['phpbb_search_results'] = array( + 'COLUMNS' => array( + 'search_key' => array('VCHAR:32', ''), + 'search_time' => array('TIMESTAMP', 0), + 'search_keywords' => array('MTEXT_UNI', ''), + 'search_authors' => array('MTEXT', ''), + ), + 'PRIMARY_KEY' => 'search_key', +); + +$schema_data['phpbb_search_wordlist'] = array( + 'COLUMNS' => array( + 'word_id' => array('UINT', NULL, 'auto_increment'), + 'word_text' => array('VCHAR_UNI', ''), + 'word_common' => array('BOOL', 0), + 'word_count' => array('UINT', 0), + ), + 'PRIMARY_KEY' => 'word_id', + 'KEYS' => array( + 'wrd_txt' => array('UNIQUE', 'word_text'), + 'wrd_cnt' => array('INDEX', 'word_count'), + ), +); + +$schema_data['phpbb_search_wordmatch'] = array( + 'COLUMNS' => array( + 'post_id' => array('UINT', 0), + 'word_id' => array('UINT', 0), + 'title_match' => array('BOOL', 0), + ), + 'KEYS' => array( + 'unq_mtch' => array('UNIQUE', array('word_id', 'post_id', 'title_match')), + 'word_id' => array('INDEX', 'word_id'), + 'post_id' => array('INDEX', 'post_id'), + ), +); + +$schema_data['phpbb_sessions'] = array( + 'COLUMNS' => array( + 'session_id' => array('CHAR:32', ''), + 'session_user_id' => array('UINT', 0), + 'session_forum_id' => array('UINT', 0), + 'session_last_visit' => array('TIMESTAMP', 0), + 'session_start' => array('TIMESTAMP', 0), + 'session_time' => array('TIMESTAMP', 0), + 'session_ip' => array('VCHAR:40', ''), + 'session_browser' => array('VCHAR:150', ''), + 'session_forwarded_for' => array('VCHAR:255', ''), + 'session_page' => array('VCHAR_UNI', ''), + 'session_viewonline' => array('BOOL', 1), + 'session_autologin' => array('BOOL', 0), + 'session_admin' => array('BOOL', 0), + ), + 'PRIMARY_KEY' => 'session_id', + 'KEYS' => array( + 'session_time' => array('INDEX', 'session_time'), + 'session_user_id' => array('INDEX', 'session_user_id'), + 'session_fid' => array('INDEX', 'session_forum_id'), + ), +); + +$schema_data['phpbb_sessions_keys'] = array( + 'COLUMNS' => array( + 'key_id' => array('CHAR:32', ''), + 'user_id' => array('UINT', 0), + 'last_ip' => array('VCHAR:40', ''), + 'last_login' => array('TIMESTAMP', 0), + ), + 'PRIMARY_KEY' => array('key_id', 'user_id'), + 'KEYS' => array( + 'last_login' => array('INDEX', 'last_login'), + ), +); + +$schema_data['phpbb_sitelist'] = array( + 'COLUMNS' => array( + 'site_id' => array('UINT', NULL, 'auto_increment'), + 'site_ip' => array('VCHAR:40', ''), + 'site_hostname' => array('VCHAR', ''), + 'ip_exclude' => array('BOOL', 0), + ), + 'PRIMARY_KEY' => 'site_id', +); + +$schema_data['phpbb_smilies'] = array( + 'COLUMNS' => array( + 'smiley_id' => array('UINT', NULL, 'auto_increment'), + // We may want to set 'code' to VCHAR:50 or check if unicode support is possible... at the moment only ASCII characters are allowed. + 'code' => array('VCHAR_UNI:50', ''), + 'emotion' => array('VCHAR_UNI:50', ''), + 'smiley_url' => array('VCHAR:50', ''), + 'smiley_width' => array('USINT', 0), + 'smiley_height' => array('USINT', 0), + 'smiley_order' => array('UINT', 0), + 'display_on_posting'=> array('BOOL', 1), + ), + 'PRIMARY_KEY' => 'smiley_id', + 'KEYS' => array( + 'display_on_post' => array('INDEX', 'display_on_posting'), + ), +); + +$schema_data['phpbb_styles'] = array( + 'COLUMNS' => array( + 'style_id' => array('UINT', NULL, 'auto_increment'), + 'style_name' => array('VCHAR_UNI:255', ''), + 'style_copyright' => array('VCHAR_UNI', ''), + 'style_active' => array('BOOL', 1), + 'style_path' => array('VCHAR:100', ''), + 'bbcode_bitfield' => array('VCHAR:255', 'kNg='), + 'style_parent_id' => array('UINT:4', 0), + 'style_parent_tree' => array('TEXT', ''), + ), + 'PRIMARY_KEY' => 'style_id', + 'KEYS' => array( + 'style_name' => array('UNIQUE', 'style_name'), + ), +); + +$schema_data['phpbb_teampage'] = array( + 'COLUMNS' => array( + 'teampage_id' => array('UINT', NULL, 'auto_increment'), + 'group_id' => array('UINT', 0), + 'teampage_name' => array('VCHAR_UNI:255', ''), + 'teampage_position' => array('UINT', 0), + 'teampage_parent' => array('UINT', 0), + ), + 'PRIMARY_KEY' => 'teampage_id', +); + +$schema_data['phpbb_topics'] = array( + 'COLUMNS' => array( + 'topic_id' => array('UINT', NULL, 'auto_increment'), + 'forum_id' => array('UINT', 0), + 'icon_id' => array('UINT', 0), + 'topic_attachment' => array('BOOL', 0), + 'topic_visibility' => array('TINT:3', 0), + 'topic_reported' => array('BOOL', 0), + 'topic_title' => array('STEXT_UNI', '', 'true_sort'), + 'topic_poster' => array('UINT', 0), + 'topic_time' => array('TIMESTAMP', 0), + 'topic_time_limit' => array('TIMESTAMP', 0), + 'topic_views' => array('UINT', 0), + 'topic_posts_approved' => array('UINT', 0), + 'topic_posts_unapproved' => array('UINT', 0), + 'topic_posts_softdeleted' => array('UINT', 0), + 'topic_status' => array('TINT:3', 0), + 'topic_type' => array('TINT:3', 0), + 'topic_first_post_id' => array('UINT', 0), + 'topic_first_poster_name' => array('VCHAR_UNI', ''), + 'topic_first_poster_colour' => array('VCHAR:6', ''), + 'topic_last_post_id' => array('UINT', 0), + 'topic_last_poster_id' => array('UINT', 0), + 'topic_last_poster_name' => array('VCHAR_UNI', ''), + 'topic_last_poster_colour' => array('VCHAR:6', ''), + 'topic_last_post_subject' => array('STEXT_UNI', ''), + 'topic_last_post_time' => array('TIMESTAMP', 0), + 'topic_last_view_time' => array('TIMESTAMP', 0), + 'topic_moved_id' => array('UINT', 0), + 'topic_bumped' => array('BOOL', 0), + 'topic_bumper' => array('UINT', 0), + 'poll_title' => array('STEXT_UNI', ''), + 'poll_start' => array('TIMESTAMP', 0), + 'poll_length' => array('TIMESTAMP', 0), + 'poll_max_options' => array('TINT:4', 1), + 'poll_last_vote' => array('TIMESTAMP', 0), + 'poll_vote_change' => array('BOOL', 0), + 'topic_delete_time' => array('TIMESTAMP', 0), + 'topic_delete_reason' => array('STEXT_UNI', ''), + 'topic_delete_user' => array('UINT', 0), + ), + 'PRIMARY_KEY' => 'topic_id', + 'KEYS' => array( + 'forum_id' => array('INDEX', 'forum_id'), + 'forum_id_type' => array('INDEX', array('forum_id', 'topic_type')), + 'last_post_time' => array('INDEX', 'topic_last_post_time'), + 'topic_visibility' => array('INDEX', 'topic_visibility'), + 'forum_appr_last' => array('INDEX', array('forum_id', 'topic_visibility', 'topic_last_post_id')), + 'fid_time_moved' => array('INDEX', array('forum_id', 'topic_last_post_time', 'topic_moved_id')), + ), +); + +$schema_data['phpbb_topics_track'] = array( + 'COLUMNS' => array( + 'user_id' => array('UINT', 0), + 'topic_id' => array('UINT', 0), + 'forum_id' => array('UINT', 0), + 'mark_time' => array('TIMESTAMP', 0), + ), + 'PRIMARY_KEY' => array('user_id', 'topic_id'), + 'KEYS' => array( + 'topic_id' => array('INDEX', 'topic_id'), + 'forum_id' => array('INDEX', 'forum_id'), + ), +); + +$schema_data['phpbb_topics_posted'] = array( + 'COLUMNS' => array( + 'user_id' => array('UINT', 0), + 'topic_id' => array('UINT', 0), + 'topic_posted' => array('BOOL', 0), + ), + 'PRIMARY_KEY' => array('user_id', 'topic_id'), +); + +$schema_data['phpbb_topics_watch'] = array( + 'COLUMNS' => array( + 'topic_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'notify_status' => array('BOOL', 0), + ), + 'KEYS' => array( + 'topic_id' => array('INDEX', 'topic_id'), + 'user_id' => array('INDEX', 'user_id'), + 'notify_stat' => array('INDEX', 'notify_status'), + ), +); + +$schema_data['phpbb_user_notifications'] = array( + 'COLUMNS' => array( + 'item_type' => array('VCHAR:255', ''), + 'item_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'method' => array('VCHAR:255', ''), + 'notify' => array('BOOL', 1), + ), +); + +$schema_data['phpbb_user_group'] = array( + 'COLUMNS' => array( + 'group_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'group_leader' => array('BOOL', 0), + 'user_pending' => array('BOOL', 1), + ), + 'KEYS' => array( + 'group_id' => array('INDEX', 'group_id'), + 'user_id' => array('INDEX', 'user_id'), + 'group_leader' => array('INDEX', 'group_leader'), + ), +); + +$schema_data['phpbb_users'] = array( + 'COLUMNS' => array( + 'user_id' => array('UINT', NULL, 'auto_increment'), + 'user_type' => array('TINT:2', 0), + 'group_id' => array('UINT', 3), + 'user_permissions' => array('MTEXT', ''), + 'user_perm_from' => array('UINT', 0), + 'user_ip' => array('VCHAR:40', ''), + 'user_regdate' => array('TIMESTAMP', 0), + 'username' => array('VCHAR_CI', ''), + 'username_clean' => array('VCHAR_CI', ''), + 'user_password' => array('VCHAR_UNI:40', ''), + 'user_passchg' => array('TIMESTAMP', 0), + 'user_pass_convert' => array('BOOL', 0), + 'user_email' => array('VCHAR_UNI:100', ''), + 'user_email_hash' => array('BINT', 0), + 'user_birthday' => array('VCHAR:10', ''), + 'user_lastvisit' => array('TIMESTAMP', 0), + 'user_lastmark' => array('TIMESTAMP', 0), + 'user_lastpost_time' => array('TIMESTAMP', 0), + 'user_lastpage' => array('VCHAR_UNI:200', ''), + 'user_last_confirm_key' => array('VCHAR:10', ''), + 'user_last_search' => array('TIMESTAMP', 0), + 'user_warnings' => array('TINT:4', 0), + 'user_last_warning' => array('TIMESTAMP', 0), + 'user_login_attempts' => array('TINT:4', 0), + 'user_inactive_reason' => array('TINT:2', 0), + 'user_inactive_time' => array('TIMESTAMP', 0), + 'user_posts' => array('UINT', 0), + 'user_lang' => array('VCHAR:30', ''), + 'user_timezone' => array('VCHAR:100', 'UTC'), + 'user_dateformat' => array('VCHAR_UNI:30', 'd M Y H:i'), + 'user_style' => array('UINT', 0), + 'user_rank' => array('UINT', 0), + 'user_colour' => array('VCHAR:6', ''), + 'user_new_privmsg' => array('INT:4', 0), + 'user_unread_privmsg' => array('INT:4', 0), + 'user_last_privmsg' => array('TIMESTAMP', 0), + 'user_message_rules' => array('BOOL', 0), + 'user_full_folder' => array('INT:11', -3), + 'user_emailtime' => array('TIMESTAMP', 0), + 'user_topic_show_days' => array('USINT', 0), + 'user_topic_sortby_type' => array('VCHAR:1', 't'), + 'user_topic_sortby_dir' => array('VCHAR:1', 'd'), + 'user_post_show_days' => array('USINT', 0), + 'user_post_sortby_type' => array('VCHAR:1', 't'), + 'user_post_sortby_dir' => array('VCHAR:1', 'a'), + 'user_notify' => array('BOOL', 0), + 'user_notify_pm' => array('BOOL', 1), + 'user_notify_type' => array('TINT:4', 0), + 'user_allow_pm' => array('BOOL', 1), + 'user_allow_viewonline' => array('BOOL', 1), + 'user_allow_viewemail' => array('BOOL', 1), + 'user_allow_massemail' => array('BOOL', 1), + 'user_options' => array('UINT:11', 230271), + 'user_avatar' => array('VCHAR', ''), + 'user_avatar_type' => array('VCHAR:255', ''), + 'user_avatar_width' => array('USINT', 0), + 'user_avatar_height' => array('USINT', 0), + 'user_sig' => array('MTEXT_UNI', ''), + 'user_sig_bbcode_uid' => array('VCHAR:8', ''), + 'user_sig_bbcode_bitfield' => array('VCHAR:255', ''), + 'user_from' => array('VCHAR_UNI:100', ''), + 'user_icq' => array('VCHAR:15', ''), + 'user_aim' => array('VCHAR_UNI', ''), + 'user_yim' => array('VCHAR_UNI', ''), + 'user_msnm' => array('VCHAR_UNI', ''), + 'user_jabber' => array('VCHAR_UNI', ''), + 'user_website' => array('VCHAR_UNI:200', ''), + 'user_occ' => array('TEXT_UNI', ''), + 'user_interests' => array('TEXT_UNI', ''), + 'user_actkey' => array('VCHAR:32', ''), + 'user_newpasswd' => array('VCHAR_UNI:40', ''), + 'user_form_salt' => array('VCHAR_UNI:32', ''), + 'user_new' => array('BOOL', 1), + 'user_reminded' => array('TINT:4', 0), + 'user_reminded_time' => array('TIMESTAMP', 0), + ), + 'PRIMARY_KEY' => 'user_id', + 'KEYS' => array( + 'user_birthday' => array('INDEX', 'user_birthday'), + 'user_email_hash' => array('INDEX', 'user_email_hash'), + 'user_type' => array('INDEX', 'user_type'), + 'username_clean' => array('UNIQUE', 'username_clean'), + ), +); + +$schema_data['phpbb_warnings'] = array( + 'COLUMNS' => array( + 'warning_id' => array('UINT', NULL, 'auto_increment'), + 'user_id' => array('UINT', 0), + 'post_id' => array('UINT', 0), + 'log_id' => array('UINT', 0), + 'warning_time' => array('TIMESTAMP', 0), + ), + 'PRIMARY_KEY' => 'warning_id', +); + +$schema_data['phpbb_words'] = array( + 'COLUMNS' => array( + 'word_id' => array('UINT', NULL, 'auto_increment'), + 'word' => array('VCHAR_UNI', ''), + 'replacement' => array('VCHAR_UNI', ''), + ), + 'PRIMARY_KEY' => 'word_id', +); + +$schema_data['phpbb_zebra'] = array( + 'COLUMNS' => array( + 'user_id' => array('UINT', 0), + 'zebra_id' => array('UINT', 0), + 'friend' => array('BOOL', 0), + 'foe' => array('BOOL', 0), + ), + 'PRIMARY_KEY' => array('user_id', 'zebra_id'), +); diff --git a/phpBB/phpbb/db/tools.php b/phpBB/phpbb/db/tools.php index 492284ffcd..dbe00f6be2 100644 --- a/phpBB/phpbb/db/tools.php +++ b/phpBB/phpbb/db/tools.php @@ -37,247 +37,257 @@ class phpbb_db_tools * The Column types for every database we support * @var array */ - var $dbms_type_map = array( - 'mysql_41' => array( - 'INT:' => 'int(%d)', - 'BINT' => 'bigint(20)', - 'UINT' => 'mediumint(8) UNSIGNED', - 'UINT:' => 'int(%d) UNSIGNED', - 'TINT:' => 'tinyint(%d)', - 'USINT' => 'smallint(4) UNSIGNED', - 'BOOL' => 'tinyint(1) UNSIGNED', - 'VCHAR' => 'varchar(255)', - 'VCHAR:' => 'varchar(%d)', - 'CHAR:' => 'char(%d)', - 'XSTEXT' => 'text', - 'XSTEXT_UNI'=> 'varchar(100)', - 'STEXT' => 'text', - 'STEXT_UNI' => 'varchar(255)', - 'TEXT' => 'text', - 'TEXT_UNI' => 'text', - 'MTEXT' => 'mediumtext', - 'MTEXT_UNI' => 'mediumtext', - 'TIMESTAMP' => 'int(11) UNSIGNED', - 'DECIMAL' => 'decimal(5,2)', - 'DECIMAL:' => 'decimal(%d,2)', - 'PDECIMAL' => 'decimal(6,3)', - 'PDECIMAL:' => 'decimal(%d,3)', - 'VCHAR_UNI' => 'varchar(255)', - 'VCHAR_UNI:'=> 'varchar(%d)', - 'VCHAR_CI' => 'varchar(255)', - 'VARBINARY' => 'varbinary(255)', - ), - - 'mysql_40' => array( - 'INT:' => 'int(%d)', - 'BINT' => 'bigint(20)', - 'UINT' => 'mediumint(8) UNSIGNED', - 'UINT:' => 'int(%d) UNSIGNED', - 'TINT:' => 'tinyint(%d)', - 'USINT' => 'smallint(4) UNSIGNED', - 'BOOL' => 'tinyint(1) UNSIGNED', - 'VCHAR' => 'varbinary(255)', - 'VCHAR:' => 'varbinary(%d)', - 'CHAR:' => 'binary(%d)', - 'XSTEXT' => 'blob', - 'XSTEXT_UNI'=> 'blob', - 'STEXT' => 'blob', - 'STEXT_UNI' => 'blob', - 'TEXT' => 'blob', - 'TEXT_UNI' => 'blob', - 'MTEXT' => 'mediumblob', - 'MTEXT_UNI' => 'mediumblob', - 'TIMESTAMP' => 'int(11) UNSIGNED', - 'DECIMAL' => 'decimal(5,2)', - 'DECIMAL:' => 'decimal(%d,2)', - 'PDECIMAL' => 'decimal(6,3)', - 'PDECIMAL:' => 'decimal(%d,3)', - 'VCHAR_UNI' => 'blob', - 'VCHAR_UNI:'=> array('varbinary(%d)', 'limit' => array('mult', 3, 255, 'blob')), - 'VCHAR_CI' => 'blob', - 'VARBINARY' => 'varbinary(255)', - ), - - 'firebird' => array( - 'INT:' => 'INTEGER', - 'BINT' => 'DOUBLE PRECISION', - 'UINT' => 'INTEGER', - 'UINT:' => 'INTEGER', - 'TINT:' => 'INTEGER', - 'USINT' => 'INTEGER', - 'BOOL' => 'INTEGER', - 'VCHAR' => 'VARCHAR(255) CHARACTER SET NONE', - 'VCHAR:' => 'VARCHAR(%d) CHARACTER SET NONE', - 'CHAR:' => 'CHAR(%d) CHARACTER SET NONE', - 'XSTEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', - 'STEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', - 'TEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', - 'MTEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', - 'XSTEXT_UNI'=> 'VARCHAR(100) CHARACTER SET UTF8', - 'STEXT_UNI' => 'VARCHAR(255) CHARACTER SET UTF8', - 'TEXT_UNI' => 'BLOB SUB_TYPE TEXT CHARACTER SET UTF8', - 'MTEXT_UNI' => 'BLOB SUB_TYPE TEXT CHARACTER SET UTF8', - 'TIMESTAMP' => 'INTEGER', - 'DECIMAL' => 'DOUBLE PRECISION', - 'DECIMAL:' => 'DOUBLE PRECISION', - 'PDECIMAL' => 'DOUBLE PRECISION', - 'PDECIMAL:' => 'DOUBLE PRECISION', - 'VCHAR_UNI' => 'VARCHAR(255) CHARACTER SET UTF8', - 'VCHAR_UNI:'=> 'VARCHAR(%d) CHARACTER SET UTF8', - 'VCHAR_CI' => 'VARCHAR(255) CHARACTER SET UTF8', - 'VARBINARY' => 'CHAR(255) CHARACTER SET NONE', - ), - - 'mssql' => array( - 'INT:' => '[int]', - 'BINT' => '[float]', - 'UINT' => '[int]', - 'UINT:' => '[int]', - 'TINT:' => '[int]', - 'USINT' => '[int]', - 'BOOL' => '[int]', - 'VCHAR' => '[varchar] (255)', - 'VCHAR:' => '[varchar] (%d)', - 'CHAR:' => '[char] (%d)', - 'XSTEXT' => '[varchar] (1000)', - 'STEXT' => '[varchar] (3000)', - 'TEXT' => '[varchar] (8000)', - 'MTEXT' => '[text]', - 'XSTEXT_UNI'=> '[varchar] (100)', - 'STEXT_UNI' => '[varchar] (255)', - 'TEXT_UNI' => '[varchar] (4000)', - 'MTEXT_UNI' => '[text]', - 'TIMESTAMP' => '[int]', - 'DECIMAL' => '[float]', - 'DECIMAL:' => '[float]', - 'PDECIMAL' => '[float]', - 'PDECIMAL:' => '[float]', - 'VCHAR_UNI' => '[varchar] (255)', - 'VCHAR_UNI:'=> '[varchar] (%d)', - 'VCHAR_CI' => '[varchar] (255)', - 'VARBINARY' => '[varchar] (255)', - ), - - 'mssqlnative' => array( - 'INT:' => '[int]', - 'BINT' => '[float]', - 'UINT' => '[int]', - 'UINT:' => '[int]', - 'TINT:' => '[int]', - 'USINT' => '[int]', - 'BOOL' => '[int]', - 'VCHAR' => '[varchar] (255)', - 'VCHAR:' => '[varchar] (%d)', - 'CHAR:' => '[char] (%d)', - 'XSTEXT' => '[varchar] (1000)', - 'STEXT' => '[varchar] (3000)', - 'TEXT' => '[varchar] (8000)', - 'MTEXT' => '[text]', - 'XSTEXT_UNI'=> '[varchar] (100)', - 'STEXT_UNI' => '[varchar] (255)', - 'TEXT_UNI' => '[varchar] (4000)', - 'MTEXT_UNI' => '[text]', - 'TIMESTAMP' => '[int]', - 'DECIMAL' => '[float]', - 'DECIMAL:' => '[float]', - 'PDECIMAL' => '[float]', - 'PDECIMAL:' => '[float]', - 'VCHAR_UNI' => '[varchar] (255)', - 'VCHAR_UNI:'=> '[varchar] (%d)', - 'VCHAR_CI' => '[varchar] (255)', - 'VARBINARY' => '[varchar] (255)', - ), - - 'oracle' => array( - 'INT:' => 'number(%d)', - 'BINT' => 'number(20)', - 'UINT' => 'number(8)', - 'UINT:' => 'number(%d)', - 'TINT:' => 'number(%d)', - 'USINT' => 'number(4)', - 'BOOL' => 'number(1)', - 'VCHAR' => 'varchar2(255)', - 'VCHAR:' => 'varchar2(%d)', - 'CHAR:' => 'char(%d)', - 'XSTEXT' => 'varchar2(1000)', - 'STEXT' => 'varchar2(3000)', - 'TEXT' => 'clob', - 'MTEXT' => 'clob', - 'XSTEXT_UNI'=> 'varchar2(300)', - 'STEXT_UNI' => 'varchar2(765)', - 'TEXT_UNI' => 'clob', - 'MTEXT_UNI' => 'clob', - 'TIMESTAMP' => 'number(11)', - 'DECIMAL' => 'number(5, 2)', - 'DECIMAL:' => 'number(%d, 2)', - 'PDECIMAL' => 'number(6, 3)', - 'PDECIMAL:' => 'number(%d, 3)', - 'VCHAR_UNI' => 'varchar2(765)', - 'VCHAR_UNI:'=> array('varchar2(%d)', 'limit' => array('mult', 3, 765, 'clob')), - 'VCHAR_CI' => 'varchar2(255)', - 'VARBINARY' => 'raw(255)', - ), - - 'sqlite' => array( - 'INT:' => 'int(%d)', - 'BINT' => 'bigint(20)', - 'UINT' => 'INTEGER UNSIGNED', //'mediumint(8) UNSIGNED', - 'UINT:' => 'INTEGER UNSIGNED', // 'int(%d) UNSIGNED', - 'TINT:' => 'tinyint(%d)', - 'USINT' => 'INTEGER UNSIGNED', //'mediumint(4) UNSIGNED', - 'BOOL' => 'INTEGER UNSIGNED', //'tinyint(1) UNSIGNED', - 'VCHAR' => 'varchar(255)', - 'VCHAR:' => 'varchar(%d)', - 'CHAR:' => 'char(%d)', - 'XSTEXT' => 'text(65535)', - 'STEXT' => 'text(65535)', - 'TEXT' => 'text(65535)', - 'MTEXT' => 'mediumtext(16777215)', - 'XSTEXT_UNI'=> 'text(65535)', - 'STEXT_UNI' => 'text(65535)', - 'TEXT_UNI' => 'text(65535)', - 'MTEXT_UNI' => 'mediumtext(16777215)', - 'TIMESTAMP' => 'INTEGER UNSIGNED', //'int(11) UNSIGNED', - 'DECIMAL' => 'decimal(5,2)', - 'DECIMAL:' => 'decimal(%d,2)', - 'PDECIMAL' => 'decimal(6,3)', - 'PDECIMAL:' => 'decimal(%d,3)', - 'VCHAR_UNI' => 'varchar(255)', - 'VCHAR_UNI:'=> 'varchar(%d)', - 'VCHAR_CI' => 'varchar(255)', - 'VARBINARY' => 'blob', - ), - - 'postgres' => array( - 'INT:' => 'INT4', - 'BINT' => 'INT8', - 'UINT' => 'INT4', // unsigned - 'UINT:' => 'INT4', // unsigned - 'USINT' => 'INT2', // unsigned - 'BOOL' => 'INT2', // unsigned - 'TINT:' => 'INT2', - 'VCHAR' => 'varchar(255)', - 'VCHAR:' => 'varchar(%d)', - 'CHAR:' => 'char(%d)', - 'XSTEXT' => 'varchar(1000)', - 'STEXT' => 'varchar(3000)', - 'TEXT' => 'varchar(8000)', - 'MTEXT' => 'TEXT', - 'XSTEXT_UNI'=> 'varchar(100)', - 'STEXT_UNI' => 'varchar(255)', - 'TEXT_UNI' => 'varchar(4000)', - 'MTEXT_UNI' => 'TEXT', - 'TIMESTAMP' => 'INT4', // unsigned - 'DECIMAL' => 'decimal(5,2)', - 'DECIMAL:' => 'decimal(%d,2)', - 'PDECIMAL' => 'decimal(6,3)', - 'PDECIMAL:' => 'decimal(%d,3)', - 'VCHAR_UNI' => 'varchar(255)', - 'VCHAR_UNI:'=> 'varchar(%d)', - 'VCHAR_CI' => 'varchar_ci', - 'VARBINARY' => 'bytea', - ), - ); + var $dbms_type_map = array(); + + /** + * Get the column types for every database we support + * + * @return array + */ + public static function get_dbms_type_map() + { + return array( + 'mysql_41' => array( + 'INT:' => 'int(%d)', + 'BINT' => 'bigint(20)', + 'UINT' => 'mediumint(8) UNSIGNED', + 'UINT:' => 'int(%d) UNSIGNED', + 'TINT:' => 'tinyint(%d)', + 'USINT' => 'smallint(4) UNSIGNED', + 'BOOL' => 'tinyint(1) UNSIGNED', + 'VCHAR' => 'varchar(255)', + 'VCHAR:' => 'varchar(%d)', + 'CHAR:' => 'char(%d)', + 'XSTEXT' => 'text', + 'XSTEXT_UNI'=> 'varchar(100)', + 'STEXT' => 'text', + 'STEXT_UNI' => 'varchar(255)', + 'TEXT' => 'text', + 'TEXT_UNI' => 'text', + 'MTEXT' => 'mediumtext', + 'MTEXT_UNI' => 'mediumtext', + 'TIMESTAMP' => 'int(11) UNSIGNED', + 'DECIMAL' => 'decimal(5,2)', + 'DECIMAL:' => 'decimal(%d,2)', + 'PDECIMAL' => 'decimal(6,3)', + 'PDECIMAL:' => 'decimal(%d,3)', + 'VCHAR_UNI' => 'varchar(255)', + 'VCHAR_UNI:'=> 'varchar(%d)', + 'VCHAR_CI' => 'varchar(255)', + 'VARBINARY' => 'varbinary(255)', + ), + + 'mysql_40' => array( + 'INT:' => 'int(%d)', + 'BINT' => 'bigint(20)', + 'UINT' => 'mediumint(8) UNSIGNED', + 'UINT:' => 'int(%d) UNSIGNED', + 'TINT:' => 'tinyint(%d)', + 'USINT' => 'smallint(4) UNSIGNED', + 'BOOL' => 'tinyint(1) UNSIGNED', + 'VCHAR' => 'varbinary(255)', + 'VCHAR:' => 'varbinary(%d)', + 'CHAR:' => 'binary(%d)', + 'XSTEXT' => 'blob', + 'XSTEXT_UNI'=> 'blob', + 'STEXT' => 'blob', + 'STEXT_UNI' => 'blob', + 'TEXT' => 'blob', + 'TEXT_UNI' => 'blob', + 'MTEXT' => 'mediumblob', + 'MTEXT_UNI' => 'mediumblob', + 'TIMESTAMP' => 'int(11) UNSIGNED', + 'DECIMAL' => 'decimal(5,2)', + 'DECIMAL:' => 'decimal(%d,2)', + 'PDECIMAL' => 'decimal(6,3)', + 'PDECIMAL:' => 'decimal(%d,3)', + 'VCHAR_UNI' => 'blob', + 'VCHAR_UNI:'=> array('varbinary(%d)', 'limit' => array('mult', 3, 255, 'blob')), + 'VCHAR_CI' => 'blob', + 'VARBINARY' => 'varbinary(255)', + ), + + 'firebird' => array( + 'INT:' => 'INTEGER', + 'BINT' => 'DOUBLE PRECISION', + 'UINT' => 'INTEGER', + 'UINT:' => 'INTEGER', + 'TINT:' => 'INTEGER', + 'USINT' => 'INTEGER', + 'BOOL' => 'INTEGER', + 'VCHAR' => 'VARCHAR(255) CHARACTER SET NONE', + 'VCHAR:' => 'VARCHAR(%d) CHARACTER SET NONE', + 'CHAR:' => 'CHAR(%d) CHARACTER SET NONE', + 'XSTEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', + 'STEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', + 'TEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', + 'MTEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', + 'XSTEXT_UNI'=> 'VARCHAR(100) CHARACTER SET UTF8', + 'STEXT_UNI' => 'VARCHAR(255) CHARACTER SET UTF8', + 'TEXT_UNI' => 'BLOB SUB_TYPE TEXT CHARACTER SET UTF8', + 'MTEXT_UNI' => 'BLOB SUB_TYPE TEXT CHARACTER SET UTF8', + 'TIMESTAMP' => 'INTEGER', + 'DECIMAL' => 'DOUBLE PRECISION', + 'DECIMAL:' => 'DOUBLE PRECISION', + 'PDECIMAL' => 'DOUBLE PRECISION', + 'PDECIMAL:' => 'DOUBLE PRECISION', + 'VCHAR_UNI' => 'VARCHAR(255) CHARACTER SET UTF8', + 'VCHAR_UNI:'=> 'VARCHAR(%d) CHARACTER SET UTF8', + 'VCHAR_CI' => 'VARCHAR(255) CHARACTER SET UTF8', + 'VARBINARY' => 'CHAR(255) CHARACTER SET NONE', + ), + + 'mssql' => array( + 'INT:' => '[int]', + 'BINT' => '[float]', + 'UINT' => '[int]', + 'UINT:' => '[int]', + 'TINT:' => '[int]', + 'USINT' => '[int]', + 'BOOL' => '[int]', + 'VCHAR' => '[varchar] (255)', + 'VCHAR:' => '[varchar] (%d)', + 'CHAR:' => '[char] (%d)', + 'XSTEXT' => '[varchar] (1000)', + 'STEXT' => '[varchar] (3000)', + 'TEXT' => '[varchar] (8000)', + 'MTEXT' => '[text]', + 'XSTEXT_UNI'=> '[varchar] (100)', + 'STEXT_UNI' => '[varchar] (255)', + 'TEXT_UNI' => '[varchar] (4000)', + 'MTEXT_UNI' => '[text]', + 'TIMESTAMP' => '[int]', + 'DECIMAL' => '[float]', + 'DECIMAL:' => '[float]', + 'PDECIMAL' => '[float]', + 'PDECIMAL:' => '[float]', + 'VCHAR_UNI' => '[varchar] (255)', + 'VCHAR_UNI:'=> '[varchar] (%d)', + 'VCHAR_CI' => '[varchar] (255)', + 'VARBINARY' => '[varchar] (255)', + ), + + 'mssqlnative' => array( + 'INT:' => '[int]', + 'BINT' => '[float]', + 'UINT' => '[int]', + 'UINT:' => '[int]', + 'TINT:' => '[int]', + 'USINT' => '[int]', + 'BOOL' => '[int]', + 'VCHAR' => '[varchar] (255)', + 'VCHAR:' => '[varchar] (%d)', + 'CHAR:' => '[char] (%d)', + 'XSTEXT' => '[varchar] (1000)', + 'STEXT' => '[varchar] (3000)', + 'TEXT' => '[varchar] (8000)', + 'MTEXT' => '[text]', + 'XSTEXT_UNI'=> '[varchar] (100)', + 'STEXT_UNI' => '[varchar] (255)', + 'TEXT_UNI' => '[varchar] (4000)', + 'MTEXT_UNI' => '[text]', + 'TIMESTAMP' => '[int]', + 'DECIMAL' => '[float]', + 'DECIMAL:' => '[float]', + 'PDECIMAL' => '[float]', + 'PDECIMAL:' => '[float]', + 'VCHAR_UNI' => '[varchar] (255)', + 'VCHAR_UNI:'=> '[varchar] (%d)', + 'VCHAR_CI' => '[varchar] (255)', + 'VARBINARY' => '[varchar] (255)', + ), + + 'oracle' => array( + 'INT:' => 'number(%d)', + 'BINT' => 'number(20)', + 'UINT' => 'number(8)', + 'UINT:' => 'number(%d)', + 'TINT:' => 'number(%d)', + 'USINT' => 'number(4)', + 'BOOL' => 'number(1)', + 'VCHAR' => 'varchar2(255)', + 'VCHAR:' => 'varchar2(%d)', + 'CHAR:' => 'char(%d)', + 'XSTEXT' => 'varchar2(1000)', + 'STEXT' => 'varchar2(3000)', + 'TEXT' => 'clob', + 'MTEXT' => 'clob', + 'XSTEXT_UNI'=> 'varchar2(300)', + 'STEXT_UNI' => 'varchar2(765)', + 'TEXT_UNI' => 'clob', + 'MTEXT_UNI' => 'clob', + 'TIMESTAMP' => 'number(11)', + 'DECIMAL' => 'number(5, 2)', + 'DECIMAL:' => 'number(%d, 2)', + 'PDECIMAL' => 'number(6, 3)', + 'PDECIMAL:' => 'number(%d, 3)', + 'VCHAR_UNI' => 'varchar2(765)', + 'VCHAR_UNI:'=> array('varchar2(%d)', 'limit' => array('mult', 3, 765, 'clob')), + 'VCHAR_CI' => 'varchar2(255)', + 'VARBINARY' => 'raw(255)', + ), + + 'sqlite' => array( + 'INT:' => 'int(%d)', + 'BINT' => 'bigint(20)', + 'UINT' => 'INTEGER UNSIGNED', //'mediumint(8) UNSIGNED', + 'UINT:' => 'INTEGER UNSIGNED', // 'int(%d) UNSIGNED', + 'TINT:' => 'tinyint(%d)', + 'USINT' => 'INTEGER UNSIGNED', //'mediumint(4) UNSIGNED', + 'BOOL' => 'INTEGER UNSIGNED', //'tinyint(1) UNSIGNED', + 'VCHAR' => 'varchar(255)', + 'VCHAR:' => 'varchar(%d)', + 'CHAR:' => 'char(%d)', + 'XSTEXT' => 'text(65535)', + 'STEXT' => 'text(65535)', + 'TEXT' => 'text(65535)', + 'MTEXT' => 'mediumtext(16777215)', + 'XSTEXT_UNI'=> 'text(65535)', + 'STEXT_UNI' => 'text(65535)', + 'TEXT_UNI' => 'text(65535)', + 'MTEXT_UNI' => 'mediumtext(16777215)', + 'TIMESTAMP' => 'INTEGER UNSIGNED', //'int(11) UNSIGNED', + 'DECIMAL' => 'decimal(5,2)', + 'DECIMAL:' => 'decimal(%d,2)', + 'PDECIMAL' => 'decimal(6,3)', + 'PDECIMAL:' => 'decimal(%d,3)', + 'VCHAR_UNI' => 'varchar(255)', + 'VCHAR_UNI:'=> 'varchar(%d)', + 'VCHAR_CI' => 'varchar(255)', + 'VARBINARY' => 'blob', + ), + + 'postgres' => array( + 'INT:' => 'INT4', + 'BINT' => 'INT8', + 'UINT' => 'INT4', // unsigned + 'UINT:' => 'INT4', // unsigned + 'USINT' => 'INT2', // unsigned + 'BOOL' => 'INT2', // unsigned + 'TINT:' => 'INT2', + 'VCHAR' => 'varchar(255)', + 'VCHAR:' => 'varchar(%d)', + 'CHAR:' => 'char(%d)', + 'XSTEXT' => 'varchar(1000)', + 'STEXT' => 'varchar(3000)', + 'TEXT' => 'varchar(8000)', + 'MTEXT' => 'TEXT', + 'XSTEXT_UNI'=> 'varchar(100)', + 'STEXT_UNI' => 'varchar(255)', + 'TEXT_UNI' => 'varchar(4000)', + 'MTEXT_UNI' => 'TEXT', + 'TIMESTAMP' => 'INT4', // unsigned + 'DECIMAL' => 'decimal(5,2)', + 'DECIMAL:' => 'decimal(%d,2)', + 'PDECIMAL' => 'decimal(6,3)', + 'PDECIMAL:' => 'decimal(%d,3)', + 'VCHAR_UNI' => 'varchar(255)', + 'VCHAR_UNI:'=> 'varchar(%d)', + 'VCHAR_CI' => 'varchar_ci', + 'VARBINARY' => 'bytea', + ), + ); + } /** * A list of types being unsigned for better reference in some db's @@ -308,6 +318,8 @@ class phpbb_db_tools $this->db = $db; $this->return_statements = $return_statements; + $this->dbms_type_map = self::get_dbms_type_map(); + // Determine mapping database type switch ($this->db->sql_layer) { -- cgit v1.2.1 From 918ffc10e173bed411a27ba627aa01f1b1c4fa51 Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 2 Sep 2013 15:34:14 -0700 Subject: [ticket/11215] Remove unnecessary comment PHPBB3-11215 --- phpBB/.htaccess | 4 ---- 1 file changed, 4 deletions(-) (limited to 'phpBB') diff --git a/phpBB/.htaccess b/phpBB/.htaccess index 80654cf729..6f33916775 100644 --- a/phpBB/.htaccess +++ b/phpBB/.htaccess @@ -1,8 +1,4 @@ -# -# Uncomment the following line if you will be using any of the URL -# rewriting below. -# RewriteEngine on # -- cgit v1.2.1 From 19074a3420029cfdf363a8afeb98443018a0e767 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Tue, 3 Sep 2013 19:44:07 +0530 Subject: [ticket/11825] Move schema_data.php into includes/ instead of phpbb/ PHPBB3-11825 --- phpBB/develop/create_schema_files.php | 2 +- phpBB/develop/mysql_upgrader.php | 2 +- phpBB/includes/db/schema_data.php | 1194 +++++++++++++++++++++++++++++++++ phpBB/phpbb/db/schema_data.php | 1194 --------------------------------- 4 files changed, 1196 insertions(+), 1196 deletions(-) create mode 100644 phpBB/includes/db/schema_data.php delete mode 100644 phpBB/phpbb/db/schema_data.php (limited to 'phpBB') diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 3aacd31e70..9ffc8d229f 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -20,7 +20,7 @@ if (!is_writable($schema_path)) define('IN_PHPBB', true); -require(dirname(__FILE__) . '/../phpbb/db/schema_data.php'); +require(dirname(__FILE__) . '/../includes/db/schema_data.php'); require(dirname(__FILE__) . '/../phpbb/db/tools.php'); $dbms_type_map = phpbb_db_tools::get_dbms_type_map(); diff --git a/phpBB/develop/mysql_upgrader.php b/phpBB/develop/mysql_upgrader.php index 340112fa38..3decee306a 100644 --- a/phpBB/develop/mysql_upgrader.php +++ b/phpBB/develop/mysql_upgrader.php @@ -56,7 +56,7 @@ echo "USE $dbname;$newline$newline"; @set_time_limit(0); -require($phpbb_root_path . 'phpbb/db/schema_data.' . $phpEx); +require($phpbb_root_path . 'includes/db/schema_data.' . $phpEx); require($phpbb_root_path . 'phpbb/db/tools.' . $phpEx); $dbms_type_map = phpbb_db_tools::get_dbms_type_map(); diff --git a/phpBB/includes/db/schema_data.php b/phpBB/includes/db/schema_data.php new file mode 100644 index 0000000000..9940a9380f --- /dev/null +++ b/phpBB/includes/db/schema_data.php @@ -0,0 +1,1194 @@ + {TABLE_DATA}) +* {TABLE_DATA}: +* COLUMNS = array({column_name} = array({column_type}, {default}, {auto_increment})) +* PRIMARY_KEY = {column_name(s)} +* KEYS = array({key_name} = array({key_type}, {column_name(s)})), +* +* Column Types: +* INT:x => SIGNED int(x) +* BINT => BIGINT +* UINT => mediumint(8) UNSIGNED +* UINT:x => int(x) UNSIGNED +* TINT:x => tinyint(x) +* USINT => smallint(4) UNSIGNED (for _order columns) +* BOOL => tinyint(1) UNSIGNED +* VCHAR => varchar(255) +* CHAR:x => char(x) +* XSTEXT_UNI => text for storing 100 characters (topic_title for example) +* STEXT_UNI => text for storing 255 characters (normal input field with a max of 255 single-byte chars) - same as VCHAR_UNI +* TEXT_UNI => text for storing 3000 characters (short text, descriptions, comments, etc.) +* MTEXT_UNI => mediumtext (post text, large text) +* VCHAR:x => varchar(x) +* TIMESTAMP => int(11) UNSIGNED +* DECIMAL => decimal number (5,2) +* DECIMAL: => decimal number (x,2) +* PDECIMAL => precision decimal number (6,3) +* PDECIMAL: => precision decimal number (x,3) +* VCHAR_UNI => varchar(255) BINARY +* VCHAR_CI => varchar_ci for postgresql, others VCHAR +*/ +$schema_data['phpbb_attachments'] = array( + 'COLUMNS' => array( + 'attach_id' => array('UINT', NULL, 'auto_increment'), + 'post_msg_id' => array('UINT', 0), + 'topic_id' => array('UINT', 0), + 'in_message' => array('BOOL', 0), + 'poster_id' => array('UINT', 0), + 'is_orphan' => array('BOOL', 1), + 'physical_filename' => array('VCHAR', ''), + 'real_filename' => array('VCHAR', ''), + 'download_count' => array('UINT', 0), + 'attach_comment' => array('TEXT_UNI', ''), + 'extension' => array('VCHAR:100', ''), + 'mimetype' => array('VCHAR:100', ''), + 'filesize' => array('UINT:20', 0), + 'filetime' => array('TIMESTAMP', 0), + 'thumbnail' => array('BOOL', 0), + ), + 'PRIMARY_KEY' => 'attach_id', + 'KEYS' => array( + 'filetime' => array('INDEX', 'filetime'), + 'post_msg_id' => array('INDEX', 'post_msg_id'), + 'topic_id' => array('INDEX', 'topic_id'), + 'poster_id' => array('INDEX', 'poster_id'), + 'is_orphan' => array('INDEX', 'is_orphan'), + ), +); + +$schema_data['phpbb_acl_groups'] = array( + 'COLUMNS' => array( + 'group_id' => array('UINT', 0), + 'forum_id' => array('UINT', 0), + 'auth_option_id' => array('UINT', 0), + 'auth_role_id' => array('UINT', 0), + 'auth_setting' => array('TINT:2', 0), + ), + 'KEYS' => array( + 'group_id' => array('INDEX', 'group_id'), + 'auth_opt_id' => array('INDEX', 'auth_option_id'), + 'auth_role_id' => array('INDEX', 'auth_role_id'), + ), +); + +$schema_data['phpbb_acl_options'] = array( + 'COLUMNS' => array( + 'auth_option_id' => array('UINT', NULL, 'auto_increment'), + 'auth_option' => array('VCHAR:50', ''), + 'is_global' => array('BOOL', 0), + 'is_local' => array('BOOL', 0), + 'founder_only' => array('BOOL', 0), + ), + 'PRIMARY_KEY' => 'auth_option_id', + 'KEYS' => array( + 'auth_option' => array('UNIQUE', 'auth_option'), + ), +); + +$schema_data['phpbb_acl_roles'] = array( + 'COLUMNS' => array( + 'role_id' => array('UINT', NULL, 'auto_increment'), + 'role_name' => array('VCHAR_UNI', ''), + 'role_description' => array('TEXT_UNI', ''), + 'role_type' => array('VCHAR:10', ''), + 'role_order' => array('USINT', 0), + ), + 'PRIMARY_KEY' => 'role_id', + 'KEYS' => array( + 'role_type' => array('INDEX', 'role_type'), + 'role_order' => array('INDEX', 'role_order'), + ), +); + +$schema_data['phpbb_acl_roles_data'] = array( + 'COLUMNS' => array( + 'role_id' => array('UINT', 0), + 'auth_option_id' => array('UINT', 0), + 'auth_setting' => array('TINT:2', 0), + ), + 'PRIMARY_KEY' => array('role_id', 'auth_option_id'), + 'KEYS' => array( + 'ath_op_id' => array('INDEX', 'auth_option_id'), + ), +); + +$schema_data['phpbb_acl_users'] = array( + 'COLUMNS' => array( + 'user_id' => array('UINT', 0), + 'forum_id' => array('UINT', 0), + 'auth_option_id' => array('UINT', 0), + 'auth_role_id' => array('UINT', 0), + 'auth_setting' => array('TINT:2', 0), + ), + 'KEYS' => array( + 'user_id' => array('INDEX', 'user_id'), + 'auth_option_id' => array('INDEX', 'auth_option_id'), + 'auth_role_id' => array('INDEX', 'auth_role_id'), + ), +); + +$schema_data['phpbb_banlist'] = array( + 'COLUMNS' => array( + 'ban_id' => array('UINT', NULL, 'auto_increment'), + 'ban_userid' => array('UINT', 0), + 'ban_ip' => array('VCHAR:40', ''), + 'ban_email' => array('VCHAR_UNI:100', ''), + 'ban_start' => array('TIMESTAMP', 0), + 'ban_end' => array('TIMESTAMP', 0), + 'ban_exclude' => array('BOOL', 0), + 'ban_reason' => array('VCHAR_UNI', ''), + 'ban_give_reason' => array('VCHAR_UNI', ''), + ), + 'PRIMARY_KEY' => 'ban_id', + 'KEYS' => array( + 'ban_end' => array('INDEX', 'ban_end'), + 'ban_user' => array('INDEX', array('ban_userid', 'ban_exclude')), + 'ban_email' => array('INDEX', array('ban_email', 'ban_exclude')), + 'ban_ip' => array('INDEX', array('ban_ip', 'ban_exclude')), + ), +); + +$schema_data['phpbb_bbcodes'] = array( + 'COLUMNS' => array( + 'bbcode_id' => array('USINT', 0), + 'bbcode_tag' => array('VCHAR:16', ''), + 'bbcode_helpline' => array('VCHAR_UNI', ''), + 'display_on_posting' => array('BOOL', 0), + 'bbcode_match' => array('TEXT_UNI', ''), + 'bbcode_tpl' => array('MTEXT_UNI', ''), + 'first_pass_match' => array('MTEXT_UNI', ''), + 'first_pass_replace' => array('MTEXT_UNI', ''), + 'second_pass_match' => array('MTEXT_UNI', ''), + 'second_pass_replace' => array('MTEXT_UNI', ''), + ), + 'PRIMARY_KEY' => 'bbcode_id', + 'KEYS' => array( + 'display_on_post' => array('INDEX', 'display_on_posting'), + ), +); + +$schema_data['phpbb_bookmarks'] = array( + 'COLUMNS' => array( + 'topic_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + ), + 'PRIMARY_KEY' => array('topic_id', 'user_id'), +); + +$schema_data['phpbb_bots'] = array( + 'COLUMNS' => array( + 'bot_id' => array('UINT', NULL, 'auto_increment'), + 'bot_active' => array('BOOL', 1), + 'bot_name' => array('STEXT_UNI', ''), + 'user_id' => array('UINT', 0), + 'bot_agent' => array('VCHAR', ''), + 'bot_ip' => array('VCHAR', ''), + ), + 'PRIMARY_KEY' => 'bot_id', + 'KEYS' => array( + 'bot_active' => array('INDEX', 'bot_active'), + ), +); + +$schema_data['phpbb_config'] = array( + 'COLUMNS' => array( + 'config_name' => array('VCHAR', ''), + 'config_value' => array('VCHAR_UNI', ''), + 'is_dynamic' => array('BOOL', 0), + ), + 'PRIMARY_KEY' => 'config_name', + 'KEYS' => array( + 'is_dynamic' => array('INDEX', 'is_dynamic'), + ), +); + +$schema_data['phpbb_config_text'] = array( + 'COLUMNS' => array( + 'config_name' => array('VCHAR', ''), + 'config_value' => array('MTEXT', ''), + ), + 'PRIMARY_KEY' => 'config_name', +); + +$schema_data['phpbb_confirm'] = array( + 'COLUMNS' => array( + 'confirm_id' => array('CHAR:32', ''), + 'session_id' => array('CHAR:32', ''), + 'confirm_type' => array('TINT:3', 0), + 'code' => array('VCHAR:8', ''), + 'seed' => array('UINT:10', 0), + 'attempts' => array('UINT', 0), + ), + 'PRIMARY_KEY' => array('session_id', 'confirm_id'), + 'KEYS' => array( + 'confirm_type' => array('INDEX', 'confirm_type'), + ), +); + +$schema_data['phpbb_disallow'] = array( + 'COLUMNS' => array( + 'disallow_id' => array('UINT', NULL, 'auto_increment'), + 'disallow_username' => array('VCHAR_UNI:255', ''), + ), + 'PRIMARY_KEY' => 'disallow_id', +); + +$schema_data['phpbb_drafts'] = array( + 'COLUMNS' => array( + 'draft_id' => array('UINT', NULL, 'auto_increment'), + 'user_id' => array('UINT', 0), + 'topic_id' => array('UINT', 0), + 'forum_id' => array('UINT', 0), + 'save_time' => array('TIMESTAMP', 0), + 'draft_subject' => array('STEXT_UNI', ''), + 'draft_message' => array('MTEXT_UNI', ''), + ), + 'PRIMARY_KEY' => 'draft_id', + 'KEYS' => array( + 'save_time' => array('INDEX', 'save_time'), + ), +); + +$schema_data['phpbb_ext'] = array( + 'COLUMNS' => array( + 'ext_name' => array('VCHAR', ''), + 'ext_active' => array('BOOL', 0), + 'ext_state' => array('TEXT', ''), + ), + 'KEYS' => array( + 'ext_name' => array('UNIQUE', 'ext_name'), + ), +); + +$schema_data['phpbb_extensions'] = array( + 'COLUMNS' => array( + 'extension_id' => array('UINT', NULL, 'auto_increment'), + 'group_id' => array('UINT', 0), + 'extension' => array('VCHAR:100', ''), + ), + 'PRIMARY_KEY' => 'extension_id', +); + +$schema_data['phpbb_extension_groups'] = array( + 'COLUMNS' => array( + 'group_id' => array('UINT', NULL, 'auto_increment'), + 'group_name' => array('VCHAR_UNI', ''), + 'cat_id' => array('TINT:2', 0), + 'allow_group' => array('BOOL', 0), + 'download_mode' => array('BOOL', 1), + 'upload_icon' => array('VCHAR', ''), + 'max_filesize' => array('UINT:20', 0), + 'allowed_forums' => array('TEXT', ''), + 'allow_in_pm' => array('BOOL', 0), + ), + 'PRIMARY_KEY' => 'group_id', +); + +$schema_data['phpbb_forums'] = array( + 'COLUMNS' => array( + 'forum_id' => array('UINT', NULL, 'auto_increment'), + 'parent_id' => array('UINT', 0), + 'left_id' => array('UINT', 0), + 'right_id' => array('UINT', 0), + 'forum_parents' => array('MTEXT', ''), + 'forum_name' => array('STEXT_UNI', ''), + 'forum_desc' => array('TEXT_UNI', ''), + 'forum_desc_bitfield' => array('VCHAR:255', ''), + 'forum_desc_options' => array('UINT:11', 7), + 'forum_desc_uid' => array('VCHAR:8', ''), + 'forum_link' => array('VCHAR_UNI', ''), + 'forum_password' => array('VCHAR_UNI:40', ''), + 'forum_style' => array('UINT', 0), + 'forum_image' => array('VCHAR', ''), + 'forum_rules' => array('TEXT_UNI', ''), + 'forum_rules_link' => array('VCHAR_UNI', ''), + 'forum_rules_bitfield' => array('VCHAR:255', ''), + 'forum_rules_options' => array('UINT:11', 7), + 'forum_rules_uid' => array('VCHAR:8', ''), + 'forum_topics_per_page' => array('TINT:4', 0), + 'forum_type' => array('TINT:4', 0), + 'forum_status' => array('TINT:4', 0), + 'forum_posts_approved' => array('UINT', 0), + 'forum_posts_unapproved' => array('UINT', 0), + 'forum_posts_softdeleted' => array('UINT', 0), + 'forum_topics_approved' => array('UINT', 0), + 'forum_topics_unapproved' => array('UINT', 0), + 'forum_topics_softdeleted' => array('UINT', 0), + 'forum_last_post_id' => array('UINT', 0), + 'forum_last_poster_id' => array('UINT', 0), + 'forum_last_post_subject' => array('STEXT_UNI', ''), + 'forum_last_post_time' => array('TIMESTAMP', 0), + 'forum_last_poster_name'=> array('VCHAR_UNI', ''), + 'forum_last_poster_colour'=> array('VCHAR:6', ''), + 'forum_flags' => array('TINT:4', 32), + 'forum_options' => array('UINT:20', 0), + 'display_subforum_list' => array('BOOL', 1), + 'display_on_index' => array('BOOL', 1), + 'enable_indexing' => array('BOOL', 1), + 'enable_icons' => array('BOOL', 1), + 'enable_prune' => array('BOOL', 0), + 'prune_next' => array('TIMESTAMP', 0), + 'prune_days' => array('UINT', 0), + 'prune_viewed' => array('UINT', 0), + 'prune_freq' => array('UINT', 0), + ), + 'PRIMARY_KEY' => 'forum_id', + 'KEYS' => array( + 'left_right_id' => array('INDEX', array('left_id', 'right_id')), + 'forum_lastpost_id' => array('INDEX', 'forum_last_post_id'), + ), +); + +$schema_data['phpbb_forums_access'] = array( + 'COLUMNS' => array( + 'forum_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'session_id' => array('CHAR:32', ''), + ), + 'PRIMARY_KEY' => array('forum_id', 'user_id', 'session_id'), +); + +$schema_data['phpbb_forums_track'] = array( + 'COLUMNS' => array( + 'user_id' => array('UINT', 0), + 'forum_id' => array('UINT', 0), + 'mark_time' => array('TIMESTAMP', 0), + ), + 'PRIMARY_KEY' => array('user_id', 'forum_id'), +); + +$schema_data['phpbb_forums_watch'] = array( + 'COLUMNS' => array( + 'forum_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'notify_status' => array('BOOL', 0), + ), + 'KEYS' => array( + 'forum_id' => array('INDEX', 'forum_id'), + 'user_id' => array('INDEX', 'user_id'), + 'notify_stat' => array('INDEX', 'notify_status'), + ), +); + +$schema_data['phpbb_groups'] = array( + 'COLUMNS' => array( + 'group_id' => array('UINT', NULL, 'auto_increment'), + 'group_type' => array('TINT:4', 1), + 'group_founder_manage' => array('BOOL', 0), + 'group_skip_auth' => array('BOOL', 0), + 'group_name' => array('VCHAR_CI', ''), + 'group_desc' => array('TEXT_UNI', ''), + 'group_desc_bitfield' => array('VCHAR:255', ''), + 'group_desc_options' => array('UINT:11', 7), + 'group_desc_uid' => array('VCHAR:8', ''), + 'group_display' => array('BOOL', 0), + 'group_avatar' => array('VCHAR', ''), + 'group_avatar_type' => array('VCHAR:255', ''), + 'group_avatar_width' => array('USINT', 0), + 'group_avatar_height' => array('USINT', 0), + 'group_rank' => array('UINT', 0), + 'group_colour' => array('VCHAR:6', ''), + 'group_sig_chars' => array('UINT', 0), + 'group_receive_pm' => array('BOOL', 0), + 'group_message_limit' => array('UINT', 0), + 'group_max_recipients' => array('UINT', 0), + 'group_legend' => array('UINT', 0), + ), + 'PRIMARY_KEY' => 'group_id', + 'KEYS' => array( + 'group_legend_name' => array('INDEX', array('group_legend', 'group_name')), + ), +); + +$schema_data['phpbb_icons'] = array( + 'COLUMNS' => array( + 'icons_id' => array('UINT', NULL, 'auto_increment'), + 'icons_url' => array('VCHAR', ''), + 'icons_width' => array('TINT:4', 0), + 'icons_height' => array('TINT:4', 0), + 'icons_order' => array('UINT', 0), + 'display_on_posting' => array('BOOL', 1), + ), + 'PRIMARY_KEY' => 'icons_id', + 'KEYS' => array( + 'display_on_posting' => array('INDEX', 'display_on_posting'), + ), +); + +$schema_data['phpbb_lang'] = array( + 'COLUMNS' => array( + 'lang_id' => array('TINT:4', NULL, 'auto_increment'), + 'lang_iso' => array('VCHAR:30', ''), + 'lang_dir' => array('VCHAR:30', ''), + 'lang_english_name' => array('VCHAR_UNI:100', ''), + 'lang_local_name' => array('VCHAR_UNI:255', ''), + 'lang_author' => array('VCHAR_UNI:255', ''), + ), + 'PRIMARY_KEY' => 'lang_id', + 'KEYS' => array( + 'lang_iso' => array('INDEX', 'lang_iso'), + ), +); + +$schema_data['phpbb_log'] = array( + 'COLUMNS' => array( + 'log_id' => array('UINT', NULL, 'auto_increment'), + 'log_type' => array('TINT:4', 0), + 'user_id' => array('UINT', 0), + 'forum_id' => array('UINT', 0), + 'topic_id' => array('UINT', 0), + 'reportee_id' => array('UINT', 0), + 'log_ip' => array('VCHAR:40', ''), + 'log_time' => array('TIMESTAMP', 0), + 'log_operation' => array('TEXT_UNI', ''), + 'log_data' => array('MTEXT_UNI', ''), + ), + 'PRIMARY_KEY' => 'log_id', + 'KEYS' => array( + 'log_type' => array('INDEX', 'log_type'), + 'log_time' => array('INDEX', 'log_time'), + 'forum_id' => array('INDEX', 'forum_id'), + 'topic_id' => array('INDEX', 'topic_id'), + 'reportee_id' => array('INDEX', 'reportee_id'), + 'user_id' => array('INDEX', 'user_id'), + ), +); + +$schema_data['phpbb_login_attempts'] = array( + 'COLUMNS' => array( + 'attempt_ip' => array('VCHAR:40', ''), + 'attempt_browser' => array('VCHAR:150', ''), + 'attempt_forwarded_for' => array('VCHAR:255', ''), + 'attempt_time' => array('TIMESTAMP', 0), + 'user_id' => array('UINT', 0), + 'username' => array('VCHAR_UNI:255', 0), + 'username_clean' => array('VCHAR_CI', 0), + ), + 'KEYS' => array( + 'att_ip' => array('INDEX', array('attempt_ip', 'attempt_time')), + 'att_for' => array('INDEX', array('attempt_forwarded_for', 'attempt_time')), + 'att_time' => array('INDEX', array('attempt_time')), + 'user_id' => array('INDEX', 'user_id'), + ), +); + +$schema_data['phpbb_moderator_cache'] = array( + 'COLUMNS' => array( + 'forum_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'username' => array('VCHAR_UNI:255', ''), + 'group_id' => array('UINT', 0), + 'group_name' => array('VCHAR_UNI', ''), + 'display_on_index' => array('BOOL', 1), + ), + 'KEYS' => array( + 'disp_idx' => array('INDEX', 'display_on_index'), + 'forum_id' => array('INDEX', 'forum_id'), + ), +); + +$schema_data['phpbb_migrations'] = array( + 'COLUMNS' => array( + 'migration_name' => array('VCHAR', ''), + 'migration_depends_on' => array('TEXT', ''), + 'migration_schema_done' => array('BOOL', 0), + 'migration_data_done' => array('BOOL', 0), + 'migration_data_state' => array('TEXT', ''), + 'migration_start_time' => array('TIMESTAMP', 0), + 'migration_end_time' => array('TIMESTAMP', 0), + ), + 'PRIMARY_KEY' => 'migration_name', +); + +$schema_data['phpbb_modules'] = array( + 'COLUMNS' => array( + 'module_id' => array('UINT', NULL, 'auto_increment'), + 'module_enabled' => array('BOOL', 1), + 'module_display' => array('BOOL', 1), + 'module_basename' => array('VCHAR', ''), + 'module_class' => array('VCHAR:10', ''), + 'parent_id' => array('UINT', 0), + 'left_id' => array('UINT', 0), + 'right_id' => array('UINT', 0), + 'module_langname' => array('VCHAR', ''), + 'module_mode' => array('VCHAR', ''), + 'module_auth' => array('VCHAR', ''), + ), + 'PRIMARY_KEY' => 'module_id', + 'KEYS' => array( + 'left_right_id' => array('INDEX', array('left_id', 'right_id')), + 'module_enabled' => array('INDEX', 'module_enabled'), + 'class_left_id' => array('INDEX', array('module_class', 'left_id')), + ), +); + +$schema_data['phpbb_notification_types'] = array( + 'COLUMNS' => array( + 'notification_type_id' => array('USINT', NULL, 'auto_increment'), + 'notification_type_name' => array('VCHAR:255', ''), + 'notification_type_enabled' => array('BOOL', 1), + ), + 'PRIMARY_KEY' => array('notification_type_id'), + 'KEYS' => array( + 'type' => array('UNIQUE', array('notification_type_name')), + ), +); + +$schema_data['phpbb_notifications'] = array( + 'COLUMNS' => array( + 'notification_id' => array('UINT:10', NULL, 'auto_increment'), + 'notification_type_id' => array('USINT', 0), + 'item_id' => array('UINT', 0), + 'item_parent_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'notification_read' => array('BOOL', 0), + 'notification_time' => array('TIMESTAMP', 1), + 'notification_data' => array('TEXT_UNI', ''), + ), + 'PRIMARY_KEY' => 'notification_id', + 'KEYS' => array( + 'item_ident' => array('INDEX', array('notification_type_id', 'item_id')), + 'user' => array('INDEX', array('user_id', 'notification_read')), + ), +); + +$schema_data['phpbb_poll_options'] = array( + 'COLUMNS' => array( + 'poll_option_id' => array('TINT:4', 0), + 'topic_id' => array('UINT', 0), + 'poll_option_text' => array('TEXT_UNI', ''), + 'poll_option_total' => array('UINT', 0), + ), + 'KEYS' => array( + 'poll_opt_id' => array('INDEX', 'poll_option_id'), + 'topic_id' => array('INDEX', 'topic_id'), + ), +); + +$schema_data['phpbb_poll_votes'] = array( + 'COLUMNS' => array( + 'topic_id' => array('UINT', 0), + 'poll_option_id' => array('TINT:4', 0), + 'vote_user_id' => array('UINT', 0), + 'vote_user_ip' => array('VCHAR:40', ''), + ), + 'KEYS' => array( + 'topic_id' => array('INDEX', 'topic_id'), + 'vote_user_id' => array('INDEX', 'vote_user_id'), + 'vote_user_ip' => array('INDEX', 'vote_user_ip'), + ), +); + +$schema_data['phpbb_posts'] = array( + 'COLUMNS' => array( + 'post_id' => array('UINT', NULL, 'auto_increment'), + 'topic_id' => array('UINT', 0), + 'forum_id' => array('UINT', 0), + 'poster_id' => array('UINT', 0), + 'icon_id' => array('UINT', 0), + 'poster_ip' => array('VCHAR:40', ''), + 'post_time' => array('TIMESTAMP', 0), + 'post_visibility' => array('TINT:3', 0), + 'post_reported' => array('BOOL', 0), + 'enable_bbcode' => array('BOOL', 1), + 'enable_smilies' => array('BOOL', 1), + 'enable_magic_url' => array('BOOL', 1), + 'enable_sig' => array('BOOL', 1), + 'post_username' => array('VCHAR_UNI:255', ''), + 'post_subject' => array('STEXT_UNI', '', 'true_sort'), + 'post_text' => array('MTEXT_UNI', ''), + 'post_checksum' => array('VCHAR:32', ''), + 'post_attachment' => array('BOOL', 0), + 'bbcode_bitfield' => array('VCHAR:255', ''), + 'bbcode_uid' => array('VCHAR:8', ''), + 'post_postcount' => array('BOOL', 1), + 'post_edit_time' => array('TIMESTAMP', 0), + 'post_edit_reason' => array('STEXT_UNI', ''), + 'post_edit_user' => array('UINT', 0), + 'post_edit_count' => array('USINT', 0), + 'post_edit_locked' => array('BOOL', 0), + 'post_delete_time' => array('TIMESTAMP', 0), + 'post_delete_reason' => array('STEXT_UNI', ''), + 'post_delete_user' => array('UINT', 0), + ), + 'PRIMARY_KEY' => 'post_id', + 'KEYS' => array( + 'forum_id' => array('INDEX', 'forum_id'), + 'topic_id' => array('INDEX', 'topic_id'), + 'poster_ip' => array('INDEX', 'poster_ip'), + 'poster_id' => array('INDEX', 'poster_id'), + 'post_visibility' => array('INDEX', 'post_visibility'), + 'post_username' => array('INDEX', 'post_username'), + 'tid_post_time' => array('INDEX', array('topic_id', 'post_time')), + ), +); + +$schema_data['phpbb_privmsgs'] = array( + 'COLUMNS' => array( + 'msg_id' => array('UINT', NULL, 'auto_increment'), + 'root_level' => array('UINT', 0), + 'author_id' => array('UINT', 0), + 'icon_id' => array('UINT', 0), + 'author_ip' => array('VCHAR:40', ''), + 'message_time' => array('TIMESTAMP', 0), + 'enable_bbcode' => array('BOOL', 1), + 'enable_smilies' => array('BOOL', 1), + 'enable_magic_url' => array('BOOL', 1), + 'enable_sig' => array('BOOL', 1), + 'message_subject' => array('STEXT_UNI', ''), + 'message_text' => array('MTEXT_UNI', ''), + 'message_edit_reason' => array('STEXT_UNI', ''), + 'message_edit_user' => array('UINT', 0), + 'message_attachment' => array('BOOL', 0), + 'bbcode_bitfield' => array('VCHAR:255', ''), + 'bbcode_uid' => array('VCHAR:8', ''), + 'message_edit_time' => array('TIMESTAMP', 0), + 'message_edit_count' => array('USINT', 0), + 'to_address' => array('TEXT_UNI', ''), + 'bcc_address' => array('TEXT_UNI', ''), + 'message_reported' => array('BOOL', 0), + ), + 'PRIMARY_KEY' => 'msg_id', + 'KEYS' => array( + 'author_ip' => array('INDEX', 'author_ip'), + 'message_time' => array('INDEX', 'message_time'), + 'author_id' => array('INDEX', 'author_id'), + 'root_level' => array('INDEX', 'root_level'), + ), +); + +$schema_data['phpbb_privmsgs_folder'] = array( + 'COLUMNS' => array( + 'folder_id' => array('UINT', NULL, 'auto_increment'), + 'user_id' => array('UINT', 0), + 'folder_name' => array('VCHAR_UNI', ''), + 'pm_count' => array('UINT', 0), + ), + 'PRIMARY_KEY' => 'folder_id', + 'KEYS' => array( + 'user_id' => array('INDEX', 'user_id'), + ), +); + +$schema_data['phpbb_privmsgs_rules'] = array( + 'COLUMNS' => array( + 'rule_id' => array('UINT', NULL, 'auto_increment'), + 'user_id' => array('UINT', 0), + 'rule_check' => array('UINT', 0), + 'rule_connection' => array('UINT', 0), + 'rule_string' => array('VCHAR_UNI', ''), + 'rule_user_id' => array('UINT', 0), + 'rule_group_id' => array('UINT', 0), + 'rule_action' => array('UINT', 0), + 'rule_folder_id' => array('INT:11', 0), + ), + 'PRIMARY_KEY' => 'rule_id', + 'KEYS' => array( + 'user_id' => array('INDEX', 'user_id'), + ), +); + +$schema_data['phpbb_privmsgs_to'] = array( + 'COLUMNS' => array( + 'msg_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'author_id' => array('UINT', 0), + 'pm_deleted' => array('BOOL', 0), + 'pm_new' => array('BOOL', 1), + 'pm_unread' => array('BOOL', 1), + 'pm_replied' => array('BOOL', 0), + 'pm_marked' => array('BOOL', 0), + 'pm_forwarded' => array('BOOL', 0), + 'folder_id' => array('INT:11', 0), + ), + 'KEYS' => array( + 'msg_id' => array('INDEX', 'msg_id'), + 'author_id' => array('INDEX', 'author_id'), + 'usr_flder_id' => array('INDEX', array('user_id', 'folder_id')), + ), +); + +$schema_data['phpbb_profile_fields'] = array( + 'COLUMNS' => array( + 'field_id' => array('UINT', NULL, 'auto_increment'), + 'field_name' => array('VCHAR_UNI', ''), + 'field_type' => array('TINT:4', 0), + 'field_ident' => array('VCHAR:20', ''), + 'field_length' => array('VCHAR:20', ''), + 'field_minlen' => array('VCHAR', ''), + 'field_maxlen' => array('VCHAR', ''), + 'field_novalue' => array('VCHAR_UNI', ''), + 'field_default_value' => array('VCHAR_UNI', ''), + 'field_validation' => array('VCHAR_UNI:20', ''), + 'field_required' => array('BOOL', 0), + 'field_show_novalue' => array('BOOL', 0), + 'field_show_on_reg' => array('BOOL', 0), + 'field_show_on_pm' => array('BOOL', 0), + 'field_show_on_vt' => array('BOOL', 0), + 'field_show_profile' => array('BOOL', 0), + 'field_hide' => array('BOOL', 0), + 'field_no_view' => array('BOOL', 0), + 'field_active' => array('BOOL', 0), + 'field_order' => array('UINT', 0), + ), + 'PRIMARY_KEY' => 'field_id', + 'KEYS' => array( + 'fld_type' => array('INDEX', 'field_type'), + 'fld_ordr' => array('INDEX', 'field_order'), + ), +); + +$schema_data['phpbb_profile_fields_data'] = array( + 'COLUMNS' => array( + 'user_id' => array('UINT', 0), + ), + 'PRIMARY_KEY' => 'user_id', +); + +$schema_data['phpbb_profile_fields_lang'] = array( + 'COLUMNS' => array( + 'field_id' => array('UINT', 0), + 'lang_id' => array('UINT', 0), + 'option_id' => array('UINT', 0), + 'field_type' => array('TINT:4', 0), + 'lang_value' => array('VCHAR_UNI', ''), + ), + 'PRIMARY_KEY' => array('field_id', 'lang_id', 'option_id'), +); + +$schema_data['phpbb_profile_lang'] = array( + 'COLUMNS' => array( + 'field_id' => array('UINT', 0), + 'lang_id' => array('UINT', 0), + 'lang_name' => array('VCHAR_UNI', ''), + 'lang_explain' => array('TEXT_UNI', ''), + 'lang_default_value' => array('VCHAR_UNI', ''), + ), + 'PRIMARY_KEY' => array('field_id', 'lang_id'), +); + +$schema_data['phpbb_ranks'] = array( + 'COLUMNS' => array( + 'rank_id' => array('UINT', NULL, 'auto_increment'), + 'rank_title' => array('VCHAR_UNI', ''), + 'rank_min' => array('UINT', 0), + 'rank_special' => array('BOOL', 0), + 'rank_image' => array('VCHAR', ''), + ), + 'PRIMARY_KEY' => 'rank_id', +); + +$schema_data['phpbb_reports'] = array( + 'COLUMNS' => array( + 'report_id' => array('UINT', NULL, 'auto_increment'), + 'reason_id' => array('USINT', 0), + 'post_id' => array('UINT', 0), + 'pm_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'user_notify' => array('BOOL', 0), + 'report_closed' => array('BOOL', 0), + 'report_time' => array('TIMESTAMP', 0), + 'report_text' => array('MTEXT_UNI', ''), + 'reported_post_text' => array('MTEXT_UNI', ''), + 'reported_post_uid' => array('VCHAR:8', ''), + 'reported_post_bitfield' => array('VCHAR:255', ''), + 'reported_post_enable_magic_url' => array('BOOL', 1), + 'reported_post_enable_smilies' => array('BOOL', 1), + 'reported_post_enable_bbcode' => array('BOOL', 1) + ), + 'PRIMARY_KEY' => 'report_id', + 'KEYS' => array( + 'post_id' => array('INDEX', 'post_id'), + 'pm_id' => array('INDEX', 'pm_id'), + ), +); + +$schema_data['phpbb_reports_reasons'] = array( + 'COLUMNS' => array( + 'reason_id' => array('USINT', NULL, 'auto_increment'), + 'reason_title' => array('VCHAR_UNI', ''), + 'reason_description' => array('MTEXT_UNI', ''), + 'reason_order' => array('USINT', 0), + ), + 'PRIMARY_KEY' => 'reason_id', +); + +$schema_data['phpbb_search_results'] = array( + 'COLUMNS' => array( + 'search_key' => array('VCHAR:32', ''), + 'search_time' => array('TIMESTAMP', 0), + 'search_keywords' => array('MTEXT_UNI', ''), + 'search_authors' => array('MTEXT', ''), + ), + 'PRIMARY_KEY' => 'search_key', +); + +$schema_data['phpbb_search_wordlist'] = array( + 'COLUMNS' => array( + 'word_id' => array('UINT', NULL, 'auto_increment'), + 'word_text' => array('VCHAR_UNI', ''), + 'word_common' => array('BOOL', 0), + 'word_count' => array('UINT', 0), + ), + 'PRIMARY_KEY' => 'word_id', + 'KEYS' => array( + 'wrd_txt' => array('UNIQUE', 'word_text'), + 'wrd_cnt' => array('INDEX', 'word_count'), + ), +); + +$schema_data['phpbb_search_wordmatch'] = array( + 'COLUMNS' => array( + 'post_id' => array('UINT', 0), + 'word_id' => array('UINT', 0), + 'title_match' => array('BOOL', 0), + ), + 'KEYS' => array( + 'unq_mtch' => array('UNIQUE', array('word_id', 'post_id', 'title_match')), + 'word_id' => array('INDEX', 'word_id'), + 'post_id' => array('INDEX', 'post_id'), + ), +); + +$schema_data['phpbb_sessions'] = array( + 'COLUMNS' => array( + 'session_id' => array('CHAR:32', ''), + 'session_user_id' => array('UINT', 0), + 'session_forum_id' => array('UINT', 0), + 'session_last_visit' => array('TIMESTAMP', 0), + 'session_start' => array('TIMESTAMP', 0), + 'session_time' => array('TIMESTAMP', 0), + 'session_ip' => array('VCHAR:40', ''), + 'session_browser' => array('VCHAR:150', ''), + 'session_forwarded_for' => array('VCHAR:255', ''), + 'session_page' => array('VCHAR_UNI', ''), + 'session_viewonline' => array('BOOL', 1), + 'session_autologin' => array('BOOL', 0), + 'session_admin' => array('BOOL', 0), + ), + 'PRIMARY_KEY' => 'session_id', + 'KEYS' => array( + 'session_time' => array('INDEX', 'session_time'), + 'session_user_id' => array('INDEX', 'session_user_id'), + 'session_fid' => array('INDEX', 'session_forum_id'), + ), +); + +$schema_data['phpbb_sessions_keys'] = array( + 'COLUMNS' => array( + 'key_id' => array('CHAR:32', ''), + 'user_id' => array('UINT', 0), + 'last_ip' => array('VCHAR:40', ''), + 'last_login' => array('TIMESTAMP', 0), + ), + 'PRIMARY_KEY' => array('key_id', 'user_id'), + 'KEYS' => array( + 'last_login' => array('INDEX', 'last_login'), + ), +); + +$schema_data['phpbb_sitelist'] = array( + 'COLUMNS' => array( + 'site_id' => array('UINT', NULL, 'auto_increment'), + 'site_ip' => array('VCHAR:40', ''), + 'site_hostname' => array('VCHAR', ''), + 'ip_exclude' => array('BOOL', 0), + ), + 'PRIMARY_KEY' => 'site_id', +); + +$schema_data['phpbb_smilies'] = array( + 'COLUMNS' => array( + 'smiley_id' => array('UINT', NULL, 'auto_increment'), + // We may want to set 'code' to VCHAR:50 or check if unicode support is possible... at the moment only ASCII characters are allowed. + 'code' => array('VCHAR_UNI:50', ''), + 'emotion' => array('VCHAR_UNI:50', ''), + 'smiley_url' => array('VCHAR:50', ''), + 'smiley_width' => array('USINT', 0), + 'smiley_height' => array('USINT', 0), + 'smiley_order' => array('UINT', 0), + 'display_on_posting'=> array('BOOL', 1), + ), + 'PRIMARY_KEY' => 'smiley_id', + 'KEYS' => array( + 'display_on_post' => array('INDEX', 'display_on_posting'), + ), +); + +$schema_data['phpbb_styles'] = array( + 'COLUMNS' => array( + 'style_id' => array('UINT', NULL, 'auto_increment'), + 'style_name' => array('VCHAR_UNI:255', ''), + 'style_copyright' => array('VCHAR_UNI', ''), + 'style_active' => array('BOOL', 1), + 'style_path' => array('VCHAR:100', ''), + 'bbcode_bitfield' => array('VCHAR:255', 'kNg='), + 'style_parent_id' => array('UINT:4', 0), + 'style_parent_tree' => array('TEXT', ''), + ), + 'PRIMARY_KEY' => 'style_id', + 'KEYS' => array( + 'style_name' => array('UNIQUE', 'style_name'), + ), +); + +$schema_data['phpbb_teampage'] = array( + 'COLUMNS' => array( + 'teampage_id' => array('UINT', NULL, 'auto_increment'), + 'group_id' => array('UINT', 0), + 'teampage_name' => array('VCHAR_UNI:255', ''), + 'teampage_position' => array('UINT', 0), + 'teampage_parent' => array('UINT', 0), + ), + 'PRIMARY_KEY' => 'teampage_id', +); + +$schema_data['phpbb_topics'] = array( + 'COLUMNS' => array( + 'topic_id' => array('UINT', NULL, 'auto_increment'), + 'forum_id' => array('UINT', 0), + 'icon_id' => array('UINT', 0), + 'topic_attachment' => array('BOOL', 0), + 'topic_visibility' => array('TINT:3', 0), + 'topic_reported' => array('BOOL', 0), + 'topic_title' => array('STEXT_UNI', '', 'true_sort'), + 'topic_poster' => array('UINT', 0), + 'topic_time' => array('TIMESTAMP', 0), + 'topic_time_limit' => array('TIMESTAMP', 0), + 'topic_views' => array('UINT', 0), + 'topic_posts_approved' => array('UINT', 0), + 'topic_posts_unapproved' => array('UINT', 0), + 'topic_posts_softdeleted' => array('UINT', 0), + 'topic_status' => array('TINT:3', 0), + 'topic_type' => array('TINT:3', 0), + 'topic_first_post_id' => array('UINT', 0), + 'topic_first_poster_name' => array('VCHAR_UNI', ''), + 'topic_first_poster_colour' => array('VCHAR:6', ''), + 'topic_last_post_id' => array('UINT', 0), + 'topic_last_poster_id' => array('UINT', 0), + 'topic_last_poster_name' => array('VCHAR_UNI', ''), + 'topic_last_poster_colour' => array('VCHAR:6', ''), + 'topic_last_post_subject' => array('STEXT_UNI', ''), + 'topic_last_post_time' => array('TIMESTAMP', 0), + 'topic_last_view_time' => array('TIMESTAMP', 0), + 'topic_moved_id' => array('UINT', 0), + 'topic_bumped' => array('BOOL', 0), + 'topic_bumper' => array('UINT', 0), + 'poll_title' => array('STEXT_UNI', ''), + 'poll_start' => array('TIMESTAMP', 0), + 'poll_length' => array('TIMESTAMP', 0), + 'poll_max_options' => array('TINT:4', 1), + 'poll_last_vote' => array('TIMESTAMP', 0), + 'poll_vote_change' => array('BOOL', 0), + 'topic_delete_time' => array('TIMESTAMP', 0), + 'topic_delete_reason' => array('STEXT_UNI', ''), + 'topic_delete_user' => array('UINT', 0), + ), + 'PRIMARY_KEY' => 'topic_id', + 'KEYS' => array( + 'forum_id' => array('INDEX', 'forum_id'), + 'forum_id_type' => array('INDEX', array('forum_id', 'topic_type')), + 'last_post_time' => array('INDEX', 'topic_last_post_time'), + 'topic_visibility' => array('INDEX', 'topic_visibility'), + 'forum_appr_last' => array('INDEX', array('forum_id', 'topic_visibility', 'topic_last_post_id')), + 'fid_time_moved' => array('INDEX', array('forum_id', 'topic_last_post_time', 'topic_moved_id')), + ), +); + +$schema_data['phpbb_topics_track'] = array( + 'COLUMNS' => array( + 'user_id' => array('UINT', 0), + 'topic_id' => array('UINT', 0), + 'forum_id' => array('UINT', 0), + 'mark_time' => array('TIMESTAMP', 0), + ), + 'PRIMARY_KEY' => array('user_id', 'topic_id'), + 'KEYS' => array( + 'topic_id' => array('INDEX', 'topic_id'), + 'forum_id' => array('INDEX', 'forum_id'), + ), +); + +$schema_data['phpbb_topics_posted'] = array( + 'COLUMNS' => array( + 'user_id' => array('UINT', 0), + 'topic_id' => array('UINT', 0), + 'topic_posted' => array('BOOL', 0), + ), + 'PRIMARY_KEY' => array('user_id', 'topic_id'), +); + +$schema_data['phpbb_topics_watch'] = array( + 'COLUMNS' => array( + 'topic_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'notify_status' => array('BOOL', 0), + ), + 'KEYS' => array( + 'topic_id' => array('INDEX', 'topic_id'), + 'user_id' => array('INDEX', 'user_id'), + 'notify_stat' => array('INDEX', 'notify_status'), + ), +); + +$schema_data['phpbb_user_notifications'] = array( + 'COLUMNS' => array( + 'item_type' => array('VCHAR:255', ''), + 'item_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'method' => array('VCHAR:255', ''), + 'notify' => array('BOOL', 1), + ), +); + +$schema_data['phpbb_user_group'] = array( + 'COLUMNS' => array( + 'group_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'group_leader' => array('BOOL', 0), + 'user_pending' => array('BOOL', 1), + ), + 'KEYS' => array( + 'group_id' => array('INDEX', 'group_id'), + 'user_id' => array('INDEX', 'user_id'), + 'group_leader' => array('INDEX', 'group_leader'), + ), +); + +$schema_data['phpbb_users'] = array( + 'COLUMNS' => array( + 'user_id' => array('UINT', NULL, 'auto_increment'), + 'user_type' => array('TINT:2', 0), + 'group_id' => array('UINT', 3), + 'user_permissions' => array('MTEXT', ''), + 'user_perm_from' => array('UINT', 0), + 'user_ip' => array('VCHAR:40', ''), + 'user_regdate' => array('TIMESTAMP', 0), + 'username' => array('VCHAR_CI', ''), + 'username_clean' => array('VCHAR_CI', ''), + 'user_password' => array('VCHAR_UNI:40', ''), + 'user_passchg' => array('TIMESTAMP', 0), + 'user_pass_convert' => array('BOOL', 0), + 'user_email' => array('VCHAR_UNI:100', ''), + 'user_email_hash' => array('BINT', 0), + 'user_birthday' => array('VCHAR:10', ''), + 'user_lastvisit' => array('TIMESTAMP', 0), + 'user_lastmark' => array('TIMESTAMP', 0), + 'user_lastpost_time' => array('TIMESTAMP', 0), + 'user_lastpage' => array('VCHAR_UNI:200', ''), + 'user_last_confirm_key' => array('VCHAR:10', ''), + 'user_last_search' => array('TIMESTAMP', 0), + 'user_warnings' => array('TINT:4', 0), + 'user_last_warning' => array('TIMESTAMP', 0), + 'user_login_attempts' => array('TINT:4', 0), + 'user_inactive_reason' => array('TINT:2', 0), + 'user_inactive_time' => array('TIMESTAMP', 0), + 'user_posts' => array('UINT', 0), + 'user_lang' => array('VCHAR:30', ''), + 'user_timezone' => array('VCHAR:100', 'UTC'), + 'user_dateformat' => array('VCHAR_UNI:30', 'd M Y H:i'), + 'user_style' => array('UINT', 0), + 'user_rank' => array('UINT', 0), + 'user_colour' => array('VCHAR:6', ''), + 'user_new_privmsg' => array('INT:4', 0), + 'user_unread_privmsg' => array('INT:4', 0), + 'user_last_privmsg' => array('TIMESTAMP', 0), + 'user_message_rules' => array('BOOL', 0), + 'user_full_folder' => array('INT:11', -3), + 'user_emailtime' => array('TIMESTAMP', 0), + 'user_topic_show_days' => array('USINT', 0), + 'user_topic_sortby_type' => array('VCHAR:1', 't'), + 'user_topic_sortby_dir' => array('VCHAR:1', 'd'), + 'user_post_show_days' => array('USINT', 0), + 'user_post_sortby_type' => array('VCHAR:1', 't'), + 'user_post_sortby_dir' => array('VCHAR:1', 'a'), + 'user_notify' => array('BOOL', 0), + 'user_notify_pm' => array('BOOL', 1), + 'user_notify_type' => array('TINT:4', 0), + 'user_allow_pm' => array('BOOL', 1), + 'user_allow_viewonline' => array('BOOL', 1), + 'user_allow_viewemail' => array('BOOL', 1), + 'user_allow_massemail' => array('BOOL', 1), + 'user_options' => array('UINT:11', 230271), + 'user_avatar' => array('VCHAR', ''), + 'user_avatar_type' => array('VCHAR:255', ''), + 'user_avatar_width' => array('USINT', 0), + 'user_avatar_height' => array('USINT', 0), + 'user_sig' => array('MTEXT_UNI', ''), + 'user_sig_bbcode_uid' => array('VCHAR:8', ''), + 'user_sig_bbcode_bitfield' => array('VCHAR:255', ''), + 'user_from' => array('VCHAR_UNI:100', ''), + 'user_icq' => array('VCHAR:15', ''), + 'user_aim' => array('VCHAR_UNI', ''), + 'user_yim' => array('VCHAR_UNI', ''), + 'user_msnm' => array('VCHAR_UNI', ''), + 'user_jabber' => array('VCHAR_UNI', ''), + 'user_website' => array('VCHAR_UNI:200', ''), + 'user_occ' => array('TEXT_UNI', ''), + 'user_interests' => array('TEXT_UNI', ''), + 'user_actkey' => array('VCHAR:32', ''), + 'user_newpasswd' => array('VCHAR_UNI:40', ''), + 'user_form_salt' => array('VCHAR_UNI:32', ''), + 'user_new' => array('BOOL', 1), + 'user_reminded' => array('TINT:4', 0), + 'user_reminded_time' => array('TIMESTAMP', 0), + ), + 'PRIMARY_KEY' => 'user_id', + 'KEYS' => array( + 'user_birthday' => array('INDEX', 'user_birthday'), + 'user_email_hash' => array('INDEX', 'user_email_hash'), + 'user_type' => array('INDEX', 'user_type'), + 'username_clean' => array('UNIQUE', 'username_clean'), + ), +); + +$schema_data['phpbb_warnings'] = array( + 'COLUMNS' => array( + 'warning_id' => array('UINT', NULL, 'auto_increment'), + 'user_id' => array('UINT', 0), + 'post_id' => array('UINT', 0), + 'log_id' => array('UINT', 0), + 'warning_time' => array('TIMESTAMP', 0), + ), + 'PRIMARY_KEY' => 'warning_id', +); + +$schema_data['phpbb_words'] = array( + 'COLUMNS' => array( + 'word_id' => array('UINT', NULL, 'auto_increment'), + 'word' => array('VCHAR_UNI', ''), + 'replacement' => array('VCHAR_UNI', ''), + ), + 'PRIMARY_KEY' => 'word_id', +); + +$schema_data['phpbb_zebra'] = array( + 'COLUMNS' => array( + 'user_id' => array('UINT', 0), + 'zebra_id' => array('UINT', 0), + 'friend' => array('BOOL', 0), + 'foe' => array('BOOL', 0), + ), + 'PRIMARY_KEY' => array('user_id', 'zebra_id'), +); diff --git a/phpBB/phpbb/db/schema_data.php b/phpBB/phpbb/db/schema_data.php deleted file mode 100644 index 9940a9380f..0000000000 --- a/phpBB/phpbb/db/schema_data.php +++ /dev/null @@ -1,1194 +0,0 @@ - {TABLE_DATA}) -* {TABLE_DATA}: -* COLUMNS = array({column_name} = array({column_type}, {default}, {auto_increment})) -* PRIMARY_KEY = {column_name(s)} -* KEYS = array({key_name} = array({key_type}, {column_name(s)})), -* -* Column Types: -* INT:x => SIGNED int(x) -* BINT => BIGINT -* UINT => mediumint(8) UNSIGNED -* UINT:x => int(x) UNSIGNED -* TINT:x => tinyint(x) -* USINT => smallint(4) UNSIGNED (for _order columns) -* BOOL => tinyint(1) UNSIGNED -* VCHAR => varchar(255) -* CHAR:x => char(x) -* XSTEXT_UNI => text for storing 100 characters (topic_title for example) -* STEXT_UNI => text for storing 255 characters (normal input field with a max of 255 single-byte chars) - same as VCHAR_UNI -* TEXT_UNI => text for storing 3000 characters (short text, descriptions, comments, etc.) -* MTEXT_UNI => mediumtext (post text, large text) -* VCHAR:x => varchar(x) -* TIMESTAMP => int(11) UNSIGNED -* DECIMAL => decimal number (5,2) -* DECIMAL: => decimal number (x,2) -* PDECIMAL => precision decimal number (6,3) -* PDECIMAL: => precision decimal number (x,3) -* VCHAR_UNI => varchar(255) BINARY -* VCHAR_CI => varchar_ci for postgresql, others VCHAR -*/ -$schema_data['phpbb_attachments'] = array( - 'COLUMNS' => array( - 'attach_id' => array('UINT', NULL, 'auto_increment'), - 'post_msg_id' => array('UINT', 0), - 'topic_id' => array('UINT', 0), - 'in_message' => array('BOOL', 0), - 'poster_id' => array('UINT', 0), - 'is_orphan' => array('BOOL', 1), - 'physical_filename' => array('VCHAR', ''), - 'real_filename' => array('VCHAR', ''), - 'download_count' => array('UINT', 0), - 'attach_comment' => array('TEXT_UNI', ''), - 'extension' => array('VCHAR:100', ''), - 'mimetype' => array('VCHAR:100', ''), - 'filesize' => array('UINT:20', 0), - 'filetime' => array('TIMESTAMP', 0), - 'thumbnail' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => 'attach_id', - 'KEYS' => array( - 'filetime' => array('INDEX', 'filetime'), - 'post_msg_id' => array('INDEX', 'post_msg_id'), - 'topic_id' => array('INDEX', 'topic_id'), - 'poster_id' => array('INDEX', 'poster_id'), - 'is_orphan' => array('INDEX', 'is_orphan'), - ), -); - -$schema_data['phpbb_acl_groups'] = array( - 'COLUMNS' => array( - 'group_id' => array('UINT', 0), - 'forum_id' => array('UINT', 0), - 'auth_option_id' => array('UINT', 0), - 'auth_role_id' => array('UINT', 0), - 'auth_setting' => array('TINT:2', 0), - ), - 'KEYS' => array( - 'group_id' => array('INDEX', 'group_id'), - 'auth_opt_id' => array('INDEX', 'auth_option_id'), - 'auth_role_id' => array('INDEX', 'auth_role_id'), - ), -); - -$schema_data['phpbb_acl_options'] = array( - 'COLUMNS' => array( - 'auth_option_id' => array('UINT', NULL, 'auto_increment'), - 'auth_option' => array('VCHAR:50', ''), - 'is_global' => array('BOOL', 0), - 'is_local' => array('BOOL', 0), - 'founder_only' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => 'auth_option_id', - 'KEYS' => array( - 'auth_option' => array('UNIQUE', 'auth_option'), - ), -); - -$schema_data['phpbb_acl_roles'] = array( - 'COLUMNS' => array( - 'role_id' => array('UINT', NULL, 'auto_increment'), - 'role_name' => array('VCHAR_UNI', ''), - 'role_description' => array('TEXT_UNI', ''), - 'role_type' => array('VCHAR:10', ''), - 'role_order' => array('USINT', 0), - ), - 'PRIMARY_KEY' => 'role_id', - 'KEYS' => array( - 'role_type' => array('INDEX', 'role_type'), - 'role_order' => array('INDEX', 'role_order'), - ), -); - -$schema_data['phpbb_acl_roles_data'] = array( - 'COLUMNS' => array( - 'role_id' => array('UINT', 0), - 'auth_option_id' => array('UINT', 0), - 'auth_setting' => array('TINT:2', 0), - ), - 'PRIMARY_KEY' => array('role_id', 'auth_option_id'), - 'KEYS' => array( - 'ath_op_id' => array('INDEX', 'auth_option_id'), - ), -); - -$schema_data['phpbb_acl_users'] = array( - 'COLUMNS' => array( - 'user_id' => array('UINT', 0), - 'forum_id' => array('UINT', 0), - 'auth_option_id' => array('UINT', 0), - 'auth_role_id' => array('UINT', 0), - 'auth_setting' => array('TINT:2', 0), - ), - 'KEYS' => array( - 'user_id' => array('INDEX', 'user_id'), - 'auth_option_id' => array('INDEX', 'auth_option_id'), - 'auth_role_id' => array('INDEX', 'auth_role_id'), - ), -); - -$schema_data['phpbb_banlist'] = array( - 'COLUMNS' => array( - 'ban_id' => array('UINT', NULL, 'auto_increment'), - 'ban_userid' => array('UINT', 0), - 'ban_ip' => array('VCHAR:40', ''), - 'ban_email' => array('VCHAR_UNI:100', ''), - 'ban_start' => array('TIMESTAMP', 0), - 'ban_end' => array('TIMESTAMP', 0), - 'ban_exclude' => array('BOOL', 0), - 'ban_reason' => array('VCHAR_UNI', ''), - 'ban_give_reason' => array('VCHAR_UNI', ''), - ), - 'PRIMARY_KEY' => 'ban_id', - 'KEYS' => array( - 'ban_end' => array('INDEX', 'ban_end'), - 'ban_user' => array('INDEX', array('ban_userid', 'ban_exclude')), - 'ban_email' => array('INDEX', array('ban_email', 'ban_exclude')), - 'ban_ip' => array('INDEX', array('ban_ip', 'ban_exclude')), - ), -); - -$schema_data['phpbb_bbcodes'] = array( - 'COLUMNS' => array( - 'bbcode_id' => array('USINT', 0), - 'bbcode_tag' => array('VCHAR:16', ''), - 'bbcode_helpline' => array('VCHAR_UNI', ''), - 'display_on_posting' => array('BOOL', 0), - 'bbcode_match' => array('TEXT_UNI', ''), - 'bbcode_tpl' => array('MTEXT_UNI', ''), - 'first_pass_match' => array('MTEXT_UNI', ''), - 'first_pass_replace' => array('MTEXT_UNI', ''), - 'second_pass_match' => array('MTEXT_UNI', ''), - 'second_pass_replace' => array('MTEXT_UNI', ''), - ), - 'PRIMARY_KEY' => 'bbcode_id', - 'KEYS' => array( - 'display_on_post' => array('INDEX', 'display_on_posting'), - ), -); - -$schema_data['phpbb_bookmarks'] = array( - 'COLUMNS' => array( - 'topic_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - ), - 'PRIMARY_KEY' => array('topic_id', 'user_id'), -); - -$schema_data['phpbb_bots'] = array( - 'COLUMNS' => array( - 'bot_id' => array('UINT', NULL, 'auto_increment'), - 'bot_active' => array('BOOL', 1), - 'bot_name' => array('STEXT_UNI', ''), - 'user_id' => array('UINT', 0), - 'bot_agent' => array('VCHAR', ''), - 'bot_ip' => array('VCHAR', ''), - ), - 'PRIMARY_KEY' => 'bot_id', - 'KEYS' => array( - 'bot_active' => array('INDEX', 'bot_active'), - ), -); - -$schema_data['phpbb_config'] = array( - 'COLUMNS' => array( - 'config_name' => array('VCHAR', ''), - 'config_value' => array('VCHAR_UNI', ''), - 'is_dynamic' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => 'config_name', - 'KEYS' => array( - 'is_dynamic' => array('INDEX', 'is_dynamic'), - ), -); - -$schema_data['phpbb_config_text'] = array( - 'COLUMNS' => array( - 'config_name' => array('VCHAR', ''), - 'config_value' => array('MTEXT', ''), - ), - 'PRIMARY_KEY' => 'config_name', -); - -$schema_data['phpbb_confirm'] = array( - 'COLUMNS' => array( - 'confirm_id' => array('CHAR:32', ''), - 'session_id' => array('CHAR:32', ''), - 'confirm_type' => array('TINT:3', 0), - 'code' => array('VCHAR:8', ''), - 'seed' => array('UINT:10', 0), - 'attempts' => array('UINT', 0), - ), - 'PRIMARY_KEY' => array('session_id', 'confirm_id'), - 'KEYS' => array( - 'confirm_type' => array('INDEX', 'confirm_type'), - ), -); - -$schema_data['phpbb_disallow'] = array( - 'COLUMNS' => array( - 'disallow_id' => array('UINT', NULL, 'auto_increment'), - 'disallow_username' => array('VCHAR_UNI:255', ''), - ), - 'PRIMARY_KEY' => 'disallow_id', -); - -$schema_data['phpbb_drafts'] = array( - 'COLUMNS' => array( - 'draft_id' => array('UINT', NULL, 'auto_increment'), - 'user_id' => array('UINT', 0), - 'topic_id' => array('UINT', 0), - 'forum_id' => array('UINT', 0), - 'save_time' => array('TIMESTAMP', 0), - 'draft_subject' => array('STEXT_UNI', ''), - 'draft_message' => array('MTEXT_UNI', ''), - ), - 'PRIMARY_KEY' => 'draft_id', - 'KEYS' => array( - 'save_time' => array('INDEX', 'save_time'), - ), -); - -$schema_data['phpbb_ext'] = array( - 'COLUMNS' => array( - 'ext_name' => array('VCHAR', ''), - 'ext_active' => array('BOOL', 0), - 'ext_state' => array('TEXT', ''), - ), - 'KEYS' => array( - 'ext_name' => array('UNIQUE', 'ext_name'), - ), -); - -$schema_data['phpbb_extensions'] = array( - 'COLUMNS' => array( - 'extension_id' => array('UINT', NULL, 'auto_increment'), - 'group_id' => array('UINT', 0), - 'extension' => array('VCHAR:100', ''), - ), - 'PRIMARY_KEY' => 'extension_id', -); - -$schema_data['phpbb_extension_groups'] = array( - 'COLUMNS' => array( - 'group_id' => array('UINT', NULL, 'auto_increment'), - 'group_name' => array('VCHAR_UNI', ''), - 'cat_id' => array('TINT:2', 0), - 'allow_group' => array('BOOL', 0), - 'download_mode' => array('BOOL', 1), - 'upload_icon' => array('VCHAR', ''), - 'max_filesize' => array('UINT:20', 0), - 'allowed_forums' => array('TEXT', ''), - 'allow_in_pm' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => 'group_id', -); - -$schema_data['phpbb_forums'] = array( - 'COLUMNS' => array( - 'forum_id' => array('UINT', NULL, 'auto_increment'), - 'parent_id' => array('UINT', 0), - 'left_id' => array('UINT', 0), - 'right_id' => array('UINT', 0), - 'forum_parents' => array('MTEXT', ''), - 'forum_name' => array('STEXT_UNI', ''), - 'forum_desc' => array('TEXT_UNI', ''), - 'forum_desc_bitfield' => array('VCHAR:255', ''), - 'forum_desc_options' => array('UINT:11', 7), - 'forum_desc_uid' => array('VCHAR:8', ''), - 'forum_link' => array('VCHAR_UNI', ''), - 'forum_password' => array('VCHAR_UNI:40', ''), - 'forum_style' => array('UINT', 0), - 'forum_image' => array('VCHAR', ''), - 'forum_rules' => array('TEXT_UNI', ''), - 'forum_rules_link' => array('VCHAR_UNI', ''), - 'forum_rules_bitfield' => array('VCHAR:255', ''), - 'forum_rules_options' => array('UINT:11', 7), - 'forum_rules_uid' => array('VCHAR:8', ''), - 'forum_topics_per_page' => array('TINT:4', 0), - 'forum_type' => array('TINT:4', 0), - 'forum_status' => array('TINT:4', 0), - 'forum_posts_approved' => array('UINT', 0), - 'forum_posts_unapproved' => array('UINT', 0), - 'forum_posts_softdeleted' => array('UINT', 0), - 'forum_topics_approved' => array('UINT', 0), - 'forum_topics_unapproved' => array('UINT', 0), - 'forum_topics_softdeleted' => array('UINT', 0), - 'forum_last_post_id' => array('UINT', 0), - 'forum_last_poster_id' => array('UINT', 0), - 'forum_last_post_subject' => array('STEXT_UNI', ''), - 'forum_last_post_time' => array('TIMESTAMP', 0), - 'forum_last_poster_name'=> array('VCHAR_UNI', ''), - 'forum_last_poster_colour'=> array('VCHAR:6', ''), - 'forum_flags' => array('TINT:4', 32), - 'forum_options' => array('UINT:20', 0), - 'display_subforum_list' => array('BOOL', 1), - 'display_on_index' => array('BOOL', 1), - 'enable_indexing' => array('BOOL', 1), - 'enable_icons' => array('BOOL', 1), - 'enable_prune' => array('BOOL', 0), - 'prune_next' => array('TIMESTAMP', 0), - 'prune_days' => array('UINT', 0), - 'prune_viewed' => array('UINT', 0), - 'prune_freq' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'forum_id', - 'KEYS' => array( - 'left_right_id' => array('INDEX', array('left_id', 'right_id')), - 'forum_lastpost_id' => array('INDEX', 'forum_last_post_id'), - ), -); - -$schema_data['phpbb_forums_access'] = array( - 'COLUMNS' => array( - 'forum_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'session_id' => array('CHAR:32', ''), - ), - 'PRIMARY_KEY' => array('forum_id', 'user_id', 'session_id'), -); - -$schema_data['phpbb_forums_track'] = array( - 'COLUMNS' => array( - 'user_id' => array('UINT', 0), - 'forum_id' => array('UINT', 0), - 'mark_time' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => array('user_id', 'forum_id'), -); - -$schema_data['phpbb_forums_watch'] = array( - 'COLUMNS' => array( - 'forum_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'notify_status' => array('BOOL', 0), - ), - 'KEYS' => array( - 'forum_id' => array('INDEX', 'forum_id'), - 'user_id' => array('INDEX', 'user_id'), - 'notify_stat' => array('INDEX', 'notify_status'), - ), -); - -$schema_data['phpbb_groups'] = array( - 'COLUMNS' => array( - 'group_id' => array('UINT', NULL, 'auto_increment'), - 'group_type' => array('TINT:4', 1), - 'group_founder_manage' => array('BOOL', 0), - 'group_skip_auth' => array('BOOL', 0), - 'group_name' => array('VCHAR_CI', ''), - 'group_desc' => array('TEXT_UNI', ''), - 'group_desc_bitfield' => array('VCHAR:255', ''), - 'group_desc_options' => array('UINT:11', 7), - 'group_desc_uid' => array('VCHAR:8', ''), - 'group_display' => array('BOOL', 0), - 'group_avatar' => array('VCHAR', ''), - 'group_avatar_type' => array('VCHAR:255', ''), - 'group_avatar_width' => array('USINT', 0), - 'group_avatar_height' => array('USINT', 0), - 'group_rank' => array('UINT', 0), - 'group_colour' => array('VCHAR:6', ''), - 'group_sig_chars' => array('UINT', 0), - 'group_receive_pm' => array('BOOL', 0), - 'group_message_limit' => array('UINT', 0), - 'group_max_recipients' => array('UINT', 0), - 'group_legend' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'group_id', - 'KEYS' => array( - 'group_legend_name' => array('INDEX', array('group_legend', 'group_name')), - ), -); - -$schema_data['phpbb_icons'] = array( - 'COLUMNS' => array( - 'icons_id' => array('UINT', NULL, 'auto_increment'), - 'icons_url' => array('VCHAR', ''), - 'icons_width' => array('TINT:4', 0), - 'icons_height' => array('TINT:4', 0), - 'icons_order' => array('UINT', 0), - 'display_on_posting' => array('BOOL', 1), - ), - 'PRIMARY_KEY' => 'icons_id', - 'KEYS' => array( - 'display_on_posting' => array('INDEX', 'display_on_posting'), - ), -); - -$schema_data['phpbb_lang'] = array( - 'COLUMNS' => array( - 'lang_id' => array('TINT:4', NULL, 'auto_increment'), - 'lang_iso' => array('VCHAR:30', ''), - 'lang_dir' => array('VCHAR:30', ''), - 'lang_english_name' => array('VCHAR_UNI:100', ''), - 'lang_local_name' => array('VCHAR_UNI:255', ''), - 'lang_author' => array('VCHAR_UNI:255', ''), - ), - 'PRIMARY_KEY' => 'lang_id', - 'KEYS' => array( - 'lang_iso' => array('INDEX', 'lang_iso'), - ), -); - -$schema_data['phpbb_log'] = array( - 'COLUMNS' => array( - 'log_id' => array('UINT', NULL, 'auto_increment'), - 'log_type' => array('TINT:4', 0), - 'user_id' => array('UINT', 0), - 'forum_id' => array('UINT', 0), - 'topic_id' => array('UINT', 0), - 'reportee_id' => array('UINT', 0), - 'log_ip' => array('VCHAR:40', ''), - 'log_time' => array('TIMESTAMP', 0), - 'log_operation' => array('TEXT_UNI', ''), - 'log_data' => array('MTEXT_UNI', ''), - ), - 'PRIMARY_KEY' => 'log_id', - 'KEYS' => array( - 'log_type' => array('INDEX', 'log_type'), - 'log_time' => array('INDEX', 'log_time'), - 'forum_id' => array('INDEX', 'forum_id'), - 'topic_id' => array('INDEX', 'topic_id'), - 'reportee_id' => array('INDEX', 'reportee_id'), - 'user_id' => array('INDEX', 'user_id'), - ), -); - -$schema_data['phpbb_login_attempts'] = array( - 'COLUMNS' => array( - 'attempt_ip' => array('VCHAR:40', ''), - 'attempt_browser' => array('VCHAR:150', ''), - 'attempt_forwarded_for' => array('VCHAR:255', ''), - 'attempt_time' => array('TIMESTAMP', 0), - 'user_id' => array('UINT', 0), - 'username' => array('VCHAR_UNI:255', 0), - 'username_clean' => array('VCHAR_CI', 0), - ), - 'KEYS' => array( - 'att_ip' => array('INDEX', array('attempt_ip', 'attempt_time')), - 'att_for' => array('INDEX', array('attempt_forwarded_for', 'attempt_time')), - 'att_time' => array('INDEX', array('attempt_time')), - 'user_id' => array('INDEX', 'user_id'), - ), -); - -$schema_data['phpbb_moderator_cache'] = array( - 'COLUMNS' => array( - 'forum_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'username' => array('VCHAR_UNI:255', ''), - 'group_id' => array('UINT', 0), - 'group_name' => array('VCHAR_UNI', ''), - 'display_on_index' => array('BOOL', 1), - ), - 'KEYS' => array( - 'disp_idx' => array('INDEX', 'display_on_index'), - 'forum_id' => array('INDEX', 'forum_id'), - ), -); - -$schema_data['phpbb_migrations'] = array( - 'COLUMNS' => array( - 'migration_name' => array('VCHAR', ''), - 'migration_depends_on' => array('TEXT', ''), - 'migration_schema_done' => array('BOOL', 0), - 'migration_data_done' => array('BOOL', 0), - 'migration_data_state' => array('TEXT', ''), - 'migration_start_time' => array('TIMESTAMP', 0), - 'migration_end_time' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => 'migration_name', -); - -$schema_data['phpbb_modules'] = array( - 'COLUMNS' => array( - 'module_id' => array('UINT', NULL, 'auto_increment'), - 'module_enabled' => array('BOOL', 1), - 'module_display' => array('BOOL', 1), - 'module_basename' => array('VCHAR', ''), - 'module_class' => array('VCHAR:10', ''), - 'parent_id' => array('UINT', 0), - 'left_id' => array('UINT', 0), - 'right_id' => array('UINT', 0), - 'module_langname' => array('VCHAR', ''), - 'module_mode' => array('VCHAR', ''), - 'module_auth' => array('VCHAR', ''), - ), - 'PRIMARY_KEY' => 'module_id', - 'KEYS' => array( - 'left_right_id' => array('INDEX', array('left_id', 'right_id')), - 'module_enabled' => array('INDEX', 'module_enabled'), - 'class_left_id' => array('INDEX', array('module_class', 'left_id')), - ), -); - -$schema_data['phpbb_notification_types'] = array( - 'COLUMNS' => array( - 'notification_type_id' => array('USINT', NULL, 'auto_increment'), - 'notification_type_name' => array('VCHAR:255', ''), - 'notification_type_enabled' => array('BOOL', 1), - ), - 'PRIMARY_KEY' => array('notification_type_id'), - 'KEYS' => array( - 'type' => array('UNIQUE', array('notification_type_name')), - ), -); - -$schema_data['phpbb_notifications'] = array( - 'COLUMNS' => array( - 'notification_id' => array('UINT:10', NULL, 'auto_increment'), - 'notification_type_id' => array('USINT', 0), - 'item_id' => array('UINT', 0), - 'item_parent_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'notification_read' => array('BOOL', 0), - 'notification_time' => array('TIMESTAMP', 1), - 'notification_data' => array('TEXT_UNI', ''), - ), - 'PRIMARY_KEY' => 'notification_id', - 'KEYS' => array( - 'item_ident' => array('INDEX', array('notification_type_id', 'item_id')), - 'user' => array('INDEX', array('user_id', 'notification_read')), - ), -); - -$schema_data['phpbb_poll_options'] = array( - 'COLUMNS' => array( - 'poll_option_id' => array('TINT:4', 0), - 'topic_id' => array('UINT', 0), - 'poll_option_text' => array('TEXT_UNI', ''), - 'poll_option_total' => array('UINT', 0), - ), - 'KEYS' => array( - 'poll_opt_id' => array('INDEX', 'poll_option_id'), - 'topic_id' => array('INDEX', 'topic_id'), - ), -); - -$schema_data['phpbb_poll_votes'] = array( - 'COLUMNS' => array( - 'topic_id' => array('UINT', 0), - 'poll_option_id' => array('TINT:4', 0), - 'vote_user_id' => array('UINT', 0), - 'vote_user_ip' => array('VCHAR:40', ''), - ), - 'KEYS' => array( - 'topic_id' => array('INDEX', 'topic_id'), - 'vote_user_id' => array('INDEX', 'vote_user_id'), - 'vote_user_ip' => array('INDEX', 'vote_user_ip'), - ), -); - -$schema_data['phpbb_posts'] = array( - 'COLUMNS' => array( - 'post_id' => array('UINT', NULL, 'auto_increment'), - 'topic_id' => array('UINT', 0), - 'forum_id' => array('UINT', 0), - 'poster_id' => array('UINT', 0), - 'icon_id' => array('UINT', 0), - 'poster_ip' => array('VCHAR:40', ''), - 'post_time' => array('TIMESTAMP', 0), - 'post_visibility' => array('TINT:3', 0), - 'post_reported' => array('BOOL', 0), - 'enable_bbcode' => array('BOOL', 1), - 'enable_smilies' => array('BOOL', 1), - 'enable_magic_url' => array('BOOL', 1), - 'enable_sig' => array('BOOL', 1), - 'post_username' => array('VCHAR_UNI:255', ''), - 'post_subject' => array('STEXT_UNI', '', 'true_sort'), - 'post_text' => array('MTEXT_UNI', ''), - 'post_checksum' => array('VCHAR:32', ''), - 'post_attachment' => array('BOOL', 0), - 'bbcode_bitfield' => array('VCHAR:255', ''), - 'bbcode_uid' => array('VCHAR:8', ''), - 'post_postcount' => array('BOOL', 1), - 'post_edit_time' => array('TIMESTAMP', 0), - 'post_edit_reason' => array('STEXT_UNI', ''), - 'post_edit_user' => array('UINT', 0), - 'post_edit_count' => array('USINT', 0), - 'post_edit_locked' => array('BOOL', 0), - 'post_delete_time' => array('TIMESTAMP', 0), - 'post_delete_reason' => array('STEXT_UNI', ''), - 'post_delete_user' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'post_id', - 'KEYS' => array( - 'forum_id' => array('INDEX', 'forum_id'), - 'topic_id' => array('INDEX', 'topic_id'), - 'poster_ip' => array('INDEX', 'poster_ip'), - 'poster_id' => array('INDEX', 'poster_id'), - 'post_visibility' => array('INDEX', 'post_visibility'), - 'post_username' => array('INDEX', 'post_username'), - 'tid_post_time' => array('INDEX', array('topic_id', 'post_time')), - ), -); - -$schema_data['phpbb_privmsgs'] = array( - 'COLUMNS' => array( - 'msg_id' => array('UINT', NULL, 'auto_increment'), - 'root_level' => array('UINT', 0), - 'author_id' => array('UINT', 0), - 'icon_id' => array('UINT', 0), - 'author_ip' => array('VCHAR:40', ''), - 'message_time' => array('TIMESTAMP', 0), - 'enable_bbcode' => array('BOOL', 1), - 'enable_smilies' => array('BOOL', 1), - 'enable_magic_url' => array('BOOL', 1), - 'enable_sig' => array('BOOL', 1), - 'message_subject' => array('STEXT_UNI', ''), - 'message_text' => array('MTEXT_UNI', ''), - 'message_edit_reason' => array('STEXT_UNI', ''), - 'message_edit_user' => array('UINT', 0), - 'message_attachment' => array('BOOL', 0), - 'bbcode_bitfield' => array('VCHAR:255', ''), - 'bbcode_uid' => array('VCHAR:8', ''), - 'message_edit_time' => array('TIMESTAMP', 0), - 'message_edit_count' => array('USINT', 0), - 'to_address' => array('TEXT_UNI', ''), - 'bcc_address' => array('TEXT_UNI', ''), - 'message_reported' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => 'msg_id', - 'KEYS' => array( - 'author_ip' => array('INDEX', 'author_ip'), - 'message_time' => array('INDEX', 'message_time'), - 'author_id' => array('INDEX', 'author_id'), - 'root_level' => array('INDEX', 'root_level'), - ), -); - -$schema_data['phpbb_privmsgs_folder'] = array( - 'COLUMNS' => array( - 'folder_id' => array('UINT', NULL, 'auto_increment'), - 'user_id' => array('UINT', 0), - 'folder_name' => array('VCHAR_UNI', ''), - 'pm_count' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'folder_id', - 'KEYS' => array( - 'user_id' => array('INDEX', 'user_id'), - ), -); - -$schema_data['phpbb_privmsgs_rules'] = array( - 'COLUMNS' => array( - 'rule_id' => array('UINT', NULL, 'auto_increment'), - 'user_id' => array('UINT', 0), - 'rule_check' => array('UINT', 0), - 'rule_connection' => array('UINT', 0), - 'rule_string' => array('VCHAR_UNI', ''), - 'rule_user_id' => array('UINT', 0), - 'rule_group_id' => array('UINT', 0), - 'rule_action' => array('UINT', 0), - 'rule_folder_id' => array('INT:11', 0), - ), - 'PRIMARY_KEY' => 'rule_id', - 'KEYS' => array( - 'user_id' => array('INDEX', 'user_id'), - ), -); - -$schema_data['phpbb_privmsgs_to'] = array( - 'COLUMNS' => array( - 'msg_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'author_id' => array('UINT', 0), - 'pm_deleted' => array('BOOL', 0), - 'pm_new' => array('BOOL', 1), - 'pm_unread' => array('BOOL', 1), - 'pm_replied' => array('BOOL', 0), - 'pm_marked' => array('BOOL', 0), - 'pm_forwarded' => array('BOOL', 0), - 'folder_id' => array('INT:11', 0), - ), - 'KEYS' => array( - 'msg_id' => array('INDEX', 'msg_id'), - 'author_id' => array('INDEX', 'author_id'), - 'usr_flder_id' => array('INDEX', array('user_id', 'folder_id')), - ), -); - -$schema_data['phpbb_profile_fields'] = array( - 'COLUMNS' => array( - 'field_id' => array('UINT', NULL, 'auto_increment'), - 'field_name' => array('VCHAR_UNI', ''), - 'field_type' => array('TINT:4', 0), - 'field_ident' => array('VCHAR:20', ''), - 'field_length' => array('VCHAR:20', ''), - 'field_minlen' => array('VCHAR', ''), - 'field_maxlen' => array('VCHAR', ''), - 'field_novalue' => array('VCHAR_UNI', ''), - 'field_default_value' => array('VCHAR_UNI', ''), - 'field_validation' => array('VCHAR_UNI:20', ''), - 'field_required' => array('BOOL', 0), - 'field_show_novalue' => array('BOOL', 0), - 'field_show_on_reg' => array('BOOL', 0), - 'field_show_on_pm' => array('BOOL', 0), - 'field_show_on_vt' => array('BOOL', 0), - 'field_show_profile' => array('BOOL', 0), - 'field_hide' => array('BOOL', 0), - 'field_no_view' => array('BOOL', 0), - 'field_active' => array('BOOL', 0), - 'field_order' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'field_id', - 'KEYS' => array( - 'fld_type' => array('INDEX', 'field_type'), - 'fld_ordr' => array('INDEX', 'field_order'), - ), -); - -$schema_data['phpbb_profile_fields_data'] = array( - 'COLUMNS' => array( - 'user_id' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'user_id', -); - -$schema_data['phpbb_profile_fields_lang'] = array( - 'COLUMNS' => array( - 'field_id' => array('UINT', 0), - 'lang_id' => array('UINT', 0), - 'option_id' => array('UINT', 0), - 'field_type' => array('TINT:4', 0), - 'lang_value' => array('VCHAR_UNI', ''), - ), - 'PRIMARY_KEY' => array('field_id', 'lang_id', 'option_id'), -); - -$schema_data['phpbb_profile_lang'] = array( - 'COLUMNS' => array( - 'field_id' => array('UINT', 0), - 'lang_id' => array('UINT', 0), - 'lang_name' => array('VCHAR_UNI', ''), - 'lang_explain' => array('TEXT_UNI', ''), - 'lang_default_value' => array('VCHAR_UNI', ''), - ), - 'PRIMARY_KEY' => array('field_id', 'lang_id'), -); - -$schema_data['phpbb_ranks'] = array( - 'COLUMNS' => array( - 'rank_id' => array('UINT', NULL, 'auto_increment'), - 'rank_title' => array('VCHAR_UNI', ''), - 'rank_min' => array('UINT', 0), - 'rank_special' => array('BOOL', 0), - 'rank_image' => array('VCHAR', ''), - ), - 'PRIMARY_KEY' => 'rank_id', -); - -$schema_data['phpbb_reports'] = array( - 'COLUMNS' => array( - 'report_id' => array('UINT', NULL, 'auto_increment'), - 'reason_id' => array('USINT', 0), - 'post_id' => array('UINT', 0), - 'pm_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'user_notify' => array('BOOL', 0), - 'report_closed' => array('BOOL', 0), - 'report_time' => array('TIMESTAMP', 0), - 'report_text' => array('MTEXT_UNI', ''), - 'reported_post_text' => array('MTEXT_UNI', ''), - 'reported_post_uid' => array('VCHAR:8', ''), - 'reported_post_bitfield' => array('VCHAR:255', ''), - 'reported_post_enable_magic_url' => array('BOOL', 1), - 'reported_post_enable_smilies' => array('BOOL', 1), - 'reported_post_enable_bbcode' => array('BOOL', 1) - ), - 'PRIMARY_KEY' => 'report_id', - 'KEYS' => array( - 'post_id' => array('INDEX', 'post_id'), - 'pm_id' => array('INDEX', 'pm_id'), - ), -); - -$schema_data['phpbb_reports_reasons'] = array( - 'COLUMNS' => array( - 'reason_id' => array('USINT', NULL, 'auto_increment'), - 'reason_title' => array('VCHAR_UNI', ''), - 'reason_description' => array('MTEXT_UNI', ''), - 'reason_order' => array('USINT', 0), - ), - 'PRIMARY_KEY' => 'reason_id', -); - -$schema_data['phpbb_search_results'] = array( - 'COLUMNS' => array( - 'search_key' => array('VCHAR:32', ''), - 'search_time' => array('TIMESTAMP', 0), - 'search_keywords' => array('MTEXT_UNI', ''), - 'search_authors' => array('MTEXT', ''), - ), - 'PRIMARY_KEY' => 'search_key', -); - -$schema_data['phpbb_search_wordlist'] = array( - 'COLUMNS' => array( - 'word_id' => array('UINT', NULL, 'auto_increment'), - 'word_text' => array('VCHAR_UNI', ''), - 'word_common' => array('BOOL', 0), - 'word_count' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'word_id', - 'KEYS' => array( - 'wrd_txt' => array('UNIQUE', 'word_text'), - 'wrd_cnt' => array('INDEX', 'word_count'), - ), -); - -$schema_data['phpbb_search_wordmatch'] = array( - 'COLUMNS' => array( - 'post_id' => array('UINT', 0), - 'word_id' => array('UINT', 0), - 'title_match' => array('BOOL', 0), - ), - 'KEYS' => array( - 'unq_mtch' => array('UNIQUE', array('word_id', 'post_id', 'title_match')), - 'word_id' => array('INDEX', 'word_id'), - 'post_id' => array('INDEX', 'post_id'), - ), -); - -$schema_data['phpbb_sessions'] = array( - 'COLUMNS' => array( - 'session_id' => array('CHAR:32', ''), - 'session_user_id' => array('UINT', 0), - 'session_forum_id' => array('UINT', 0), - 'session_last_visit' => array('TIMESTAMP', 0), - 'session_start' => array('TIMESTAMP', 0), - 'session_time' => array('TIMESTAMP', 0), - 'session_ip' => array('VCHAR:40', ''), - 'session_browser' => array('VCHAR:150', ''), - 'session_forwarded_for' => array('VCHAR:255', ''), - 'session_page' => array('VCHAR_UNI', ''), - 'session_viewonline' => array('BOOL', 1), - 'session_autologin' => array('BOOL', 0), - 'session_admin' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => 'session_id', - 'KEYS' => array( - 'session_time' => array('INDEX', 'session_time'), - 'session_user_id' => array('INDEX', 'session_user_id'), - 'session_fid' => array('INDEX', 'session_forum_id'), - ), -); - -$schema_data['phpbb_sessions_keys'] = array( - 'COLUMNS' => array( - 'key_id' => array('CHAR:32', ''), - 'user_id' => array('UINT', 0), - 'last_ip' => array('VCHAR:40', ''), - 'last_login' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => array('key_id', 'user_id'), - 'KEYS' => array( - 'last_login' => array('INDEX', 'last_login'), - ), -); - -$schema_data['phpbb_sitelist'] = array( - 'COLUMNS' => array( - 'site_id' => array('UINT', NULL, 'auto_increment'), - 'site_ip' => array('VCHAR:40', ''), - 'site_hostname' => array('VCHAR', ''), - 'ip_exclude' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => 'site_id', -); - -$schema_data['phpbb_smilies'] = array( - 'COLUMNS' => array( - 'smiley_id' => array('UINT', NULL, 'auto_increment'), - // We may want to set 'code' to VCHAR:50 or check if unicode support is possible... at the moment only ASCII characters are allowed. - 'code' => array('VCHAR_UNI:50', ''), - 'emotion' => array('VCHAR_UNI:50', ''), - 'smiley_url' => array('VCHAR:50', ''), - 'smiley_width' => array('USINT', 0), - 'smiley_height' => array('USINT', 0), - 'smiley_order' => array('UINT', 0), - 'display_on_posting'=> array('BOOL', 1), - ), - 'PRIMARY_KEY' => 'smiley_id', - 'KEYS' => array( - 'display_on_post' => array('INDEX', 'display_on_posting'), - ), -); - -$schema_data['phpbb_styles'] = array( - 'COLUMNS' => array( - 'style_id' => array('UINT', NULL, 'auto_increment'), - 'style_name' => array('VCHAR_UNI:255', ''), - 'style_copyright' => array('VCHAR_UNI', ''), - 'style_active' => array('BOOL', 1), - 'style_path' => array('VCHAR:100', ''), - 'bbcode_bitfield' => array('VCHAR:255', 'kNg='), - 'style_parent_id' => array('UINT:4', 0), - 'style_parent_tree' => array('TEXT', ''), - ), - 'PRIMARY_KEY' => 'style_id', - 'KEYS' => array( - 'style_name' => array('UNIQUE', 'style_name'), - ), -); - -$schema_data['phpbb_teampage'] = array( - 'COLUMNS' => array( - 'teampage_id' => array('UINT', NULL, 'auto_increment'), - 'group_id' => array('UINT', 0), - 'teampage_name' => array('VCHAR_UNI:255', ''), - 'teampage_position' => array('UINT', 0), - 'teampage_parent' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'teampage_id', -); - -$schema_data['phpbb_topics'] = array( - 'COLUMNS' => array( - 'topic_id' => array('UINT', NULL, 'auto_increment'), - 'forum_id' => array('UINT', 0), - 'icon_id' => array('UINT', 0), - 'topic_attachment' => array('BOOL', 0), - 'topic_visibility' => array('TINT:3', 0), - 'topic_reported' => array('BOOL', 0), - 'topic_title' => array('STEXT_UNI', '', 'true_sort'), - 'topic_poster' => array('UINT', 0), - 'topic_time' => array('TIMESTAMP', 0), - 'topic_time_limit' => array('TIMESTAMP', 0), - 'topic_views' => array('UINT', 0), - 'topic_posts_approved' => array('UINT', 0), - 'topic_posts_unapproved' => array('UINT', 0), - 'topic_posts_softdeleted' => array('UINT', 0), - 'topic_status' => array('TINT:3', 0), - 'topic_type' => array('TINT:3', 0), - 'topic_first_post_id' => array('UINT', 0), - 'topic_first_poster_name' => array('VCHAR_UNI', ''), - 'topic_first_poster_colour' => array('VCHAR:6', ''), - 'topic_last_post_id' => array('UINT', 0), - 'topic_last_poster_id' => array('UINT', 0), - 'topic_last_poster_name' => array('VCHAR_UNI', ''), - 'topic_last_poster_colour' => array('VCHAR:6', ''), - 'topic_last_post_subject' => array('STEXT_UNI', ''), - 'topic_last_post_time' => array('TIMESTAMP', 0), - 'topic_last_view_time' => array('TIMESTAMP', 0), - 'topic_moved_id' => array('UINT', 0), - 'topic_bumped' => array('BOOL', 0), - 'topic_bumper' => array('UINT', 0), - 'poll_title' => array('STEXT_UNI', ''), - 'poll_start' => array('TIMESTAMP', 0), - 'poll_length' => array('TIMESTAMP', 0), - 'poll_max_options' => array('TINT:4', 1), - 'poll_last_vote' => array('TIMESTAMP', 0), - 'poll_vote_change' => array('BOOL', 0), - 'topic_delete_time' => array('TIMESTAMP', 0), - 'topic_delete_reason' => array('STEXT_UNI', ''), - 'topic_delete_user' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'topic_id', - 'KEYS' => array( - 'forum_id' => array('INDEX', 'forum_id'), - 'forum_id_type' => array('INDEX', array('forum_id', 'topic_type')), - 'last_post_time' => array('INDEX', 'topic_last_post_time'), - 'topic_visibility' => array('INDEX', 'topic_visibility'), - 'forum_appr_last' => array('INDEX', array('forum_id', 'topic_visibility', 'topic_last_post_id')), - 'fid_time_moved' => array('INDEX', array('forum_id', 'topic_last_post_time', 'topic_moved_id')), - ), -); - -$schema_data['phpbb_topics_track'] = array( - 'COLUMNS' => array( - 'user_id' => array('UINT', 0), - 'topic_id' => array('UINT', 0), - 'forum_id' => array('UINT', 0), - 'mark_time' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => array('user_id', 'topic_id'), - 'KEYS' => array( - 'topic_id' => array('INDEX', 'topic_id'), - 'forum_id' => array('INDEX', 'forum_id'), - ), -); - -$schema_data['phpbb_topics_posted'] = array( - 'COLUMNS' => array( - 'user_id' => array('UINT', 0), - 'topic_id' => array('UINT', 0), - 'topic_posted' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => array('user_id', 'topic_id'), -); - -$schema_data['phpbb_topics_watch'] = array( - 'COLUMNS' => array( - 'topic_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'notify_status' => array('BOOL', 0), - ), - 'KEYS' => array( - 'topic_id' => array('INDEX', 'topic_id'), - 'user_id' => array('INDEX', 'user_id'), - 'notify_stat' => array('INDEX', 'notify_status'), - ), -); - -$schema_data['phpbb_user_notifications'] = array( - 'COLUMNS' => array( - 'item_type' => array('VCHAR:255', ''), - 'item_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'method' => array('VCHAR:255', ''), - 'notify' => array('BOOL', 1), - ), -); - -$schema_data['phpbb_user_group'] = array( - 'COLUMNS' => array( - 'group_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'group_leader' => array('BOOL', 0), - 'user_pending' => array('BOOL', 1), - ), - 'KEYS' => array( - 'group_id' => array('INDEX', 'group_id'), - 'user_id' => array('INDEX', 'user_id'), - 'group_leader' => array('INDEX', 'group_leader'), - ), -); - -$schema_data['phpbb_users'] = array( - 'COLUMNS' => array( - 'user_id' => array('UINT', NULL, 'auto_increment'), - 'user_type' => array('TINT:2', 0), - 'group_id' => array('UINT', 3), - 'user_permissions' => array('MTEXT', ''), - 'user_perm_from' => array('UINT', 0), - 'user_ip' => array('VCHAR:40', ''), - 'user_regdate' => array('TIMESTAMP', 0), - 'username' => array('VCHAR_CI', ''), - 'username_clean' => array('VCHAR_CI', ''), - 'user_password' => array('VCHAR_UNI:40', ''), - 'user_passchg' => array('TIMESTAMP', 0), - 'user_pass_convert' => array('BOOL', 0), - 'user_email' => array('VCHAR_UNI:100', ''), - 'user_email_hash' => array('BINT', 0), - 'user_birthday' => array('VCHAR:10', ''), - 'user_lastvisit' => array('TIMESTAMP', 0), - 'user_lastmark' => array('TIMESTAMP', 0), - 'user_lastpost_time' => array('TIMESTAMP', 0), - 'user_lastpage' => array('VCHAR_UNI:200', ''), - 'user_last_confirm_key' => array('VCHAR:10', ''), - 'user_last_search' => array('TIMESTAMP', 0), - 'user_warnings' => array('TINT:4', 0), - 'user_last_warning' => array('TIMESTAMP', 0), - 'user_login_attempts' => array('TINT:4', 0), - 'user_inactive_reason' => array('TINT:2', 0), - 'user_inactive_time' => array('TIMESTAMP', 0), - 'user_posts' => array('UINT', 0), - 'user_lang' => array('VCHAR:30', ''), - 'user_timezone' => array('VCHAR:100', 'UTC'), - 'user_dateformat' => array('VCHAR_UNI:30', 'd M Y H:i'), - 'user_style' => array('UINT', 0), - 'user_rank' => array('UINT', 0), - 'user_colour' => array('VCHAR:6', ''), - 'user_new_privmsg' => array('INT:4', 0), - 'user_unread_privmsg' => array('INT:4', 0), - 'user_last_privmsg' => array('TIMESTAMP', 0), - 'user_message_rules' => array('BOOL', 0), - 'user_full_folder' => array('INT:11', -3), - 'user_emailtime' => array('TIMESTAMP', 0), - 'user_topic_show_days' => array('USINT', 0), - 'user_topic_sortby_type' => array('VCHAR:1', 't'), - 'user_topic_sortby_dir' => array('VCHAR:1', 'd'), - 'user_post_show_days' => array('USINT', 0), - 'user_post_sortby_type' => array('VCHAR:1', 't'), - 'user_post_sortby_dir' => array('VCHAR:1', 'a'), - 'user_notify' => array('BOOL', 0), - 'user_notify_pm' => array('BOOL', 1), - 'user_notify_type' => array('TINT:4', 0), - 'user_allow_pm' => array('BOOL', 1), - 'user_allow_viewonline' => array('BOOL', 1), - 'user_allow_viewemail' => array('BOOL', 1), - 'user_allow_massemail' => array('BOOL', 1), - 'user_options' => array('UINT:11', 230271), - 'user_avatar' => array('VCHAR', ''), - 'user_avatar_type' => array('VCHAR:255', ''), - 'user_avatar_width' => array('USINT', 0), - 'user_avatar_height' => array('USINT', 0), - 'user_sig' => array('MTEXT_UNI', ''), - 'user_sig_bbcode_uid' => array('VCHAR:8', ''), - 'user_sig_bbcode_bitfield' => array('VCHAR:255', ''), - 'user_from' => array('VCHAR_UNI:100', ''), - 'user_icq' => array('VCHAR:15', ''), - 'user_aim' => array('VCHAR_UNI', ''), - 'user_yim' => array('VCHAR_UNI', ''), - 'user_msnm' => array('VCHAR_UNI', ''), - 'user_jabber' => array('VCHAR_UNI', ''), - 'user_website' => array('VCHAR_UNI:200', ''), - 'user_occ' => array('TEXT_UNI', ''), - 'user_interests' => array('TEXT_UNI', ''), - 'user_actkey' => array('VCHAR:32', ''), - 'user_newpasswd' => array('VCHAR_UNI:40', ''), - 'user_form_salt' => array('VCHAR_UNI:32', ''), - 'user_new' => array('BOOL', 1), - 'user_reminded' => array('TINT:4', 0), - 'user_reminded_time' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => 'user_id', - 'KEYS' => array( - 'user_birthday' => array('INDEX', 'user_birthday'), - 'user_email_hash' => array('INDEX', 'user_email_hash'), - 'user_type' => array('INDEX', 'user_type'), - 'username_clean' => array('UNIQUE', 'username_clean'), - ), -); - -$schema_data['phpbb_warnings'] = array( - 'COLUMNS' => array( - 'warning_id' => array('UINT', NULL, 'auto_increment'), - 'user_id' => array('UINT', 0), - 'post_id' => array('UINT', 0), - 'log_id' => array('UINT', 0), - 'warning_time' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => 'warning_id', -); - -$schema_data['phpbb_words'] = array( - 'COLUMNS' => array( - 'word_id' => array('UINT', NULL, 'auto_increment'), - 'word' => array('VCHAR_UNI', ''), - 'replacement' => array('VCHAR_UNI', ''), - ), - 'PRIMARY_KEY' => 'word_id', -); - -$schema_data['phpbb_zebra'] = array( - 'COLUMNS' => array( - 'user_id' => array('UINT', 0), - 'zebra_id' => array('UINT', 0), - 'friend' => array('BOOL', 0), - 'foe' => array('BOOL', 0), - ), - 'PRIMARY_KEY' => array('user_id', 'zebra_id'), -); -- cgit v1.2.1 From 010da72f64ce325c27fb68c5c142ec01e1e53e61 Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 3 Sep 2013 16:16:23 -0700 Subject: [ticket/11824] Add option for mod_rewrite PHPBB3-11824 --- phpBB/config/services.yml | 2 +- phpBB/includes/acp/acp_board.php | 48 +++++++++++++++++++++++ phpBB/includes/functions.php | 6 +-- phpBB/install/schemas/schema_data.sql | 1 + phpBB/language/en/acp/board.php | 4 ++ phpBB/phpbb/controller/helper.php | 22 +++++------ phpBB/phpbb/db/migration/data/310/mod_rewrite.php | 25 ++++++++++++ 7 files changed, 92 insertions(+), 16 deletions(-) create mode 100644 phpBB/phpbb/db/migration/data/310/mod_rewrite.php (limited to 'phpBB') diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 2808e81337..ba3b2a407d 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -90,7 +90,7 @@ services: arguments: - @template - @user - - @request + - @config - %core.root_path% - %core.php_ext% diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 12e2a1bf72..5b73cb3772 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -375,6 +375,7 @@ class acp_board 'use_system_cron' => array('lang' => 'USE_SYSTEM_CRON', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'legend2' => 'PATH_SETTINGS', + 'enable_mod_rewrite' => array('lang' => 'MOD_REWRITE_ENABLE', 'validate' => 'bool', 'type' => 'custom', 'method' => 'enable_mod_rewrite', 'explain' => true), 'smilies_path' => array('lang' => 'SMILIES_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true), 'icons_path' => array('lang' => 'ICONS_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true), 'upload_icons_path' => array('lang' => 'UPLOAD_ICONS_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true), @@ -994,4 +995,51 @@ class acp_board $cache->destroy('sql', FORUMS_TABLE); } + /** + * Option to enable/disable removal of 'app.php' from URLs + * + * Note that if mod_rewrite is on, URLs without app.php will still work, + * but any paths generated by the controller helper url() method will + * contain app.php. + * + * @param int $value The current config value + * @param string $key The config key + * @return string The HTML for the form field + */ + function enable_mod_rewrite($value, $key) + { + global $user, $config; + + // Determine whether mod_rewrite is enabled on the server + // NOTE: This only works on Apache servers on which PHP is NOT + // installed as CGI. In that case, there is no way for PHP to + // determine whether or not the Apache module is enabled. + // + // To be clear on the value of $mod_rewite: + // null = Cannot determine whether or not the server has mod_rewrite + // enabled + // false = Can determine that the server does NOT have mod_rewrite + // enabled + // true = Can determine that the server DOES have mod_rewrite_enabled + $mod_rewrite = null; + if (function_exists('apache_get_modules')) + { + $mod_rewrite = (bool) in_array('mod_rewrite', apache_get_modules()); + } + + // If $message is false, mod_rewrite is enabled. + // Otherwise, it is not and we need to: + // 1) disable the form field + // 2) make sure the config value is set to 0 + // 3) append the message to the return + $value = ($mod_rewrite === false) ? 0 : $value; + $message = $mod_rewrite === null ? 'MOD_REWRITE_INFORMATION_UNAVAILABLE' : ($mod_rewrite === false ? 'MOD_REWRITE_DISABLED' : false); + + // Let's do some friendly HTML injection if we want to disable the + // form field because h_radio() has no pretty way of doing so + $field_name = 'config[enable_mod_rewrite]' . ($message === 'MOD_REWRITE_DISABLED' ? '" disabled="disabled' : ''); + + return h_radio($field_name, array(1 => 'YES', 0 => 'NO'), $value) . + ($message !== false ? '
      ' . $user->lang($message) . '' : ''); + } } diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 4d2d704a43..3ff7716edd 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5733,6 +5733,7 @@ function phpbb_create_symfony_request(phpbb_request $request) */ function phpbb_get_web_root_path(Request $symfony_request, $phpbb_root_path = '') { + global $config, $phpEx, $request; static $path; if (null !== $path) { @@ -5748,9 +5749,8 @@ function phpbb_get_web_root_path(Request $symfony_request, $phpbb_root_path = '' $corrections = substr_count($path_info, '/'); - // When URL Rewriting is enabled, app.php is optional. We have to - // correct for it not being there - if (strpos($symfony_request->getRequestUri(), $symfony_request->getScriptName()) === false) + // We need to account for whether or not app.php is in the URL + if (strpos($symfony_request->server->get('REQUEST_URI', ''), 'app.' . $phpEx) !== false) { $corrections -= 1; } diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 0a31b89aab..68f3c32f72 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -101,6 +101,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('email_function_nam INSERT INTO phpbb_config (config_name, config_value) VALUES ('email_max_chunk_size', '50'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('email_package_size', '20'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('enable_confirm', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('enable_mod_rewrite', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('enable_pm_icons', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('enable_post_confirm', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_enable', '1'); diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index ce15dfefb4..369317e6c9 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -427,6 +427,10 @@ $lang = array_merge($lang, array( 'FORCE_SERVER_VARS_EXPLAIN' => 'If set to yes the server settings defined here will be used in favour of the automatically determined values.', 'ICONS_PATH' => 'Post icons storage path', 'ICONS_PATH_EXPLAIN' => 'Path under your phpBB root directory, e.g. images/icons.', + 'MOD_REWRITE_ENABLE' => 'Enable URL Rewriting', + 'MOD_REWRITE_ENABLE_EXPLAIN' => 'When disabled, URL paths will include app.php. When enabled, URL paths will not include app.php.
      This option requires the Apache module mod_rewrite to be enabled and the appropriate rewrite rules must be present in .htaccess.', + 'MOD_REWRITE_DISABLED' => 'The mod_rewrite module on your Apache web server is disabled. Enable the module or contact your web hosting provider if you wish to enable this feature.', + 'MOD_REWRITE_INFORMATION_UNAVAILABLE' => 'We are unable to determine whether or not this server supports URL rewriting. This setting may be enabled but if URL rewriting is not available, paths generated by this board (such as for use in links) may be broken. Contact your web hosting provider if you are unsure whether or not you can safely enable this feature.', 'PATH_SETTINGS' => 'Path settings', 'RANKS_PATH' => 'Rank image storage path', 'RANKS_PATH_EXPLAIN' => 'Path under your phpBB root directory, e.g. images/ranks.', diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 4d240f9380..3f6ef24ce0 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -36,10 +36,10 @@ class phpbb_controller_helper protected $user; /** - * Request object - * @var phpbb_request + * config object + * @var phpbb_config */ - protected $request; + protected $config; /** * phpBB root path @@ -61,11 +61,11 @@ class phpbb_controller_helper * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP extension */ - public function __construct(phpbb_template $template, phpbb_user $user, phpbb_request_interface $request, $phpbb_root_path, $php_ext) + public function __construct(phpbb_template $template, phpbb_user $user, phpbb_config $config, $phpbb_root_path, $php_ext) { $this->template = $template; $this->user = $user; - $this->request = $request; + $this->config = $config; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; } @@ -109,14 +109,12 @@ class phpbb_controller_helper $route = substr($route, 0, $route_delim); } - $request_uri = $this->request->variable('REQUEST_URI', '', false, phpbb_request::SERVER); - $script_name = $this->request->variable('SCRIPT_NAME', '', false, phpbb_request::SERVER); - - // If the app.php file is being used (no rewrite) keep it in the URL. - // Otherwise, don't include it. + // If enable_mod_rewrite is false, we not need to include app.php $route_prefix = $this->phpbb_root_path; - $parts = explode('/', $script_name); - $route_prefix .= strpos($request_uri, $script_name) === 0 ? array_pop($parts) . '/' : ''; + if (empty($this->config['enable_mod_rewrite'])) + { + $route_prefix .= 'app.' . $this->php_ext . '/'; + } return append_sid($route_prefix . "$route" . $route_params, $params, $is_amp, $session_id); } diff --git a/phpBB/phpbb/db/migration/data/310/mod_rewrite.php b/phpBB/phpbb/db/migration/data/310/mod_rewrite.php new file mode 100644 index 0000000000..ca8937e817 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/310/mod_rewrite.php @@ -0,0 +1,25 @@ + Date: Wed, 4 Sep 2013 13:37:39 +0200 Subject: [ticket/11829] Use report_closed to determine status in MCP report_details Instead of using post_reported of the post or message_reported of the pm, use report_closed of the report itself to reliably determine whether this particular report is closed or not in the report_details view of the MCP. This fixes a bug where the report_details view would not show that the report shown was closed and display a "Close report" button that had no effect. PHPBB3-11829 --- phpBB/includes/mcp/mcp_pm_reports.php | 1 + phpBB/includes/mcp/mcp_reports.php | 1 + phpBB/styles/prosilver/template/mcp_post.html | 4 ++-- phpBB/styles/subsilver2/template/mcp_post.html | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/mcp/mcp_pm_reports.php b/phpBB/includes/mcp/mcp_pm_reports.php index 77bc7680e6..0a33c80a90 100644 --- a/phpBB/includes/mcp/mcp_pm_reports.php +++ b/phpBB/includes/mcp/mcp_pm_reports.php @@ -166,6 +166,7 @@ class mcp_pm_reports 'S_CLOSE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=pm_reports&mode=pm_report_details&r=' . $report_id), 'S_CAN_VIEWIP' => $auth->acl_getf_global('m_info'), 'S_POST_REPORTED' => $pm_info['message_reported'], + 'S_REPORT_CLOSED' => $report['report_closed'], 'S_USER_NOTES' => true, 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=pm_reports&mode=pm_report_details&r=' . $report_id), diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index def5422be2..b13c8b20c6 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -192,6 +192,7 @@ class mcp_reports 'S_POST_REPORTED' => $post_info['post_reported'], 'S_POST_UNAPPROVED' => !$post_info['post_approved'], 'S_POST_LOCKED' => $post_info['post_edit_locked'], + 'S_REPORT_CLOSED' => $report['report_closed'], 'S_USER_NOTES' => true, 'U_EDIT' => ($auth->acl_get('m_edit', $post_info['forum_id'])) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}") : '', diff --git a/phpBB/styles/prosilver/template/mcp_post.html b/phpBB/styles/prosilver/template/mcp_post.html index f8403ffccd..11f63a3ea2 100644 --- a/phpBB/styles/prosilver/template/mcp_post.html +++ b/phpBB/styles/prosilver/template/mcp_post.html @@ -13,7 +13,7 @@

      {L_REPORT_REASON}: {REPORT_REASON_TITLE}

      {L_REPORTED} {L_POST_BY_AUTHOR} {REPORTER_FULL} « {REPORT_DATE}

      - +

      {L_REPORT_CLOSED}

      @@ -31,7 +31,7 @@
      - +   diff --git a/phpBB/styles/subsilver2/template/mcp_post.html b/phpBB/styles/subsilver2/template/mcp_post.html index 6fb68ca680..d026ac22c0 100644 --- a/phpBB/styles/subsilver2/template/mcp_post.html +++ b/phpBB/styles/subsilver2/template/mcp_post.html @@ -28,7 +28,7 @@ - {L_REPORT_CLOSED}   + {L_REPORT_CLOSED}   -- cgit v1.2.1 From 3dfad1f01e61c80fe89721d7bd826fd77f79cf9a Mon Sep 17 00:00:00 2001 From: rechosen Date: Fri, 6 Sep 2013 15:04:52 +0200 Subject: [ticket/9550] Add the core.viewtopic_post_rowset_data event to viewtopic.php To allow extra fields added to the query retrieving post data to be used for setting template variables, they need to be added to the post rowset. This commit adds the core.viewtopic_post_rowset_data event that enables extension developers to modify the post rowset when the database row is still available. PHPBB3-9550 --- phpBB/viewtopic.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index bc54a249a9..af2056fdeb 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1012,7 +1012,7 @@ while ($row = $db->sql_fetchrow($result)) } } - $rowset[$row['post_id']] = array( + $rowset_data = array( 'hide_post' => (($row['foe'] || $row['post_visibility'] == ITEM_DELETED) && ($view != 'show' || $post_id != $row['post_id'])) ? true : false, 'post_id' => $row['post_id'], @@ -1047,6 +1047,19 @@ while ($row = $db->sql_fetchrow($result)) 'foe' => $row['foe'], ); + /** + * Modify the post rowset containing data to be displayed with posts + * + * @event core.viewtopic_post_rowset_data + * @var array rowset_data Array with the rowset data for this post + * @var array row Array with original user and post data + * @since 3.1-A1 + */ + $vars = array('rowset_data', 'row'); + extract($phpbb_dispatcher->trigger_event('core.viewtopic_post_rowset_data', compact($vars))); + + $rowset[$row['post_id']] = $rowset_data; + // Define the global bbcode bitfield, will be used to load bbcodes $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']); -- cgit v1.2.1 From b7eca27f2adfc9742f98166991a2f2546a6c5e73 Mon Sep 17 00:00:00 2001 From: Nathan Date: Fri, 6 Sep 2013 12:28:46 -0500 Subject: [ticket/11831] Update fabpot/goutte to 1.0.* PHPBB3-11831 --- phpBB/composer.json | 2 +- phpBB/composer.lock | 450 ++++++++++++++++++++++++++++++++++------------------ 2 files changed, 298 insertions(+), 154 deletions(-) (limited to 'phpBB') diff --git a/phpBB/composer.json b/phpBB/composer.json index 9e73936322..4b3fe8ebb3 100644 --- a/phpBB/composer.json +++ b/phpBB/composer.json @@ -1,6 +1,6 @@ { "require-dev": { - "fabpot/goutte": "v0.1.0", + "fabpot/goutte": "1.0.*", "phpunit/dbunit": "1.2.*", "phpunit/phpunit": "3.7.*", "phing/phing": "2.4.*" diff --git a/phpBB/composer.lock b/phpBB/composer.lock index c7194c2fb5..61ba0fdebc 100644 --- a/phpBB/composer.lock +++ b/phpBB/composer.lock @@ -3,34 +3,38 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "ef6d05965cca4e390fff7ce63e9d2d49", + "hash": "ec5fbbc971057677b452c4600e7501c6", "packages": [ ], "packages-dev": [ { "name": "fabpot/goutte", - "version": "v0.1.0", + "version": "v1.0.3", "source": { "type": "git", - "url": "https://github.com/fabpot/Goutte", - "reference": "v0.1.0" + "url": "https://github.com/fabpot/Goutte.git", + "reference": "75c9f23c4122caf4ea3e87a42a00b471366e707f" }, "dist": { "type": "zip", - "url": "https://github.com/fabpot/Goutte/archive/v0.1.0.zip", - "reference": "v0.1.0", + "url": "https://api.github.com/repos/fabpot/Goutte/zipball/75c9f23c4122caf4ea3e87a42a00b471366e707f", + "reference": "75c9f23c4122caf4ea3e87a42a00b471366e707f", "shasum": "" }, "require": { "ext-curl": "*", - "guzzle/guzzle": "3.0.*", + "guzzle/http": ">=3.0.5,<3.8-dev", "php": ">=5.3.0", - "symfony/browser-kit": "2.1.*", - "symfony/css-selector": "2.1.*", - "symfony/dom-crawler": "2.1.*", - "symfony/finder": "2.1.*", - "symfony/process": "2.1.*" + "symfony/browser-kit": "~2.1", + "symfony/css-selector": "~2.1", + "symfony/dom-crawler": "~2.1", + "symfony/finder": "~2.1", + "symfony/process": "~2.1" + }, + "require-dev": { + "guzzle/plugin-history": ">=3.0.5,<3.8-dev", + "guzzle/plugin-mock": ">=3.0.5,<3.8-dev" }, "type": "application", "extra": { @@ -58,70 +62,85 @@ "keywords": [ "scraper" ], - "time": "2012-12-02 13:44:35" + "time": "2013-08-16 06:03:22" }, { - "name": "guzzle/guzzle", - "version": "v3.0.7", + "name": "guzzle/common", + "version": "v3.7.2", + "target-dir": "Guzzle/Common", "source": { "type": "git", - "url": "https://github.com/guzzle/guzzle", - "reference": "v3.0.7" + "url": "https://github.com/guzzle/common.git", + "reference": "70c8e8a624e2ef1657ce0045d845bee9f46a325e" }, "dist": { "type": "zip", - "url": "https://github.com/guzzle/guzzle/archive/v3.0.7.zip", - "reference": "v3.0.7", + "url": "https://api.github.com/repos/guzzle/common/zipball/70c8e8a624e2ef1657ce0045d845bee9f46a325e", + "reference": "70c8e8a624e2ef1657ce0045d845bee9f46a325e", "shasum": "" }, "require": { - "ext-curl": "*", "php": ">=5.3.2", "symfony/event-dispatcher": ">=2.1" }, - "replace": { - "guzzle/batch": "self.version", - "guzzle/cache": "self.version", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.7-dev" + } + }, + "autoload": { + "psr-0": { + "Guzzle\\Common": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Common libraries used by Guzzle", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "collection", + "common", + "event", + "exception" + ], + "time": "2013-08-02 18:31:05" + }, + { + "name": "guzzle/http", + "version": "v3.7.2", + "target-dir": "Guzzle/Http", + "source": { + "type": "git", + "url": "https://github.com/guzzle/http.git", + "reference": "a18954489d8af2e04ee9e3bafd3bf703b55459ff" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/http/zipball/a18954489d8af2e04ee9e3bafd3bf703b55459ff", + "reference": "a18954489d8af2e04ee9e3bafd3bf703b55459ff", + "shasum": "" + }, + "require": { "guzzle/common": "self.version", - "guzzle/http": "self.version", - "guzzle/inflection": "self.version", - "guzzle/iterator": "self.version", - "guzzle/log": "self.version", "guzzle/parser": "self.version", - "guzzle/plugin": "self.version", - "guzzle/plugin-async": "self.version", - "guzzle/plugin-backoff": "self.version", - "guzzle/plugin-cache": "self.version", - "guzzle/plugin-cookie": "self.version", - "guzzle/plugin-curlauth": "self.version", - "guzzle/plugin-history": "self.version", - "guzzle/plugin-log": "self.version", - "guzzle/plugin-md5": "self.version", - "guzzle/plugin-mock": "self.version", - "guzzle/plugin-oauth": "self.version", - "guzzle/service": "self.version", - "guzzle/stream": "self.version" + "guzzle/stream": "self.version", + "php": ">=5.3.2" }, - "require-dev": { - "doctrine/common": "*", - "monolog/monolog": "1.*", - "phpunit/phpunit": "3.7.*", - "symfony/class-loader": "*", - "zend/zend-cache1": "1.12", - "zend/zend-log1": "1.12", - "zendframework/zend-cache": "2.0.*", - "zendframework/zend-log": "2.0.*" + "suggest": { + "ext-curl": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.7-dev" } }, "autoload": { "psr-0": { - "Guzzle\\Tests": "tests/", - "Guzzle": "src/" + "Guzzle\\Http": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -133,37 +152,128 @@ "name": "Michael Dowling", "email": "mtdowling@gmail.com", "homepage": "https://github.com/mtdowling" - }, - { - "name": "Guzzle Community", - "homepage": "https://github.com/guzzle/guzzle/contributors" } ], - "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients", + "description": "HTTP libraries used by Guzzle", "homepage": "http://guzzlephp.org/", "keywords": [ + "Guzzle", "client", "curl", - "framework", "http", - "http client", - "rest", - "web service" + "http client" ], - "time": "2012-12-19 23:06:35" + "time": "2013-07-30 22:07:23" + }, + { + "name": "guzzle/parser", + "version": "v3.7.2", + "target-dir": "Guzzle/Parser", + "source": { + "type": "git", + "url": "https://github.com/guzzle/parser.git", + "reference": "a25c2ddda1c52fb69a4ee56eb530b13ddd9573c2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/parser/zipball/a25c2ddda1c52fb69a4ee56eb530b13ddd9573c2", + "reference": "a25c2ddda1c52fb69a4ee56eb530b13ddd9573c2", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.7-dev" + } + }, + "autoload": { + "psr-0": { + "Guzzle\\Parser": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Interchangeable parsers used by Guzzle", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "URI Template", + "cookie", + "http", + "message", + "url" + ], + "time": "2013-07-11 22:46:03" + }, + { + "name": "guzzle/stream", + "version": "v3.7.2", + "target-dir": "Guzzle/Stream", + "source": { + "type": "git", + "url": "https://github.com/guzzle/stream.git", + "reference": "a86111d9ac7db31d65a053c825869409fe8fc83f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/stream/zipball/a86111d9ac7db31d65a053c825869409fe8fc83f", + "reference": "a86111d9ac7db31d65a053c825869409fe8fc83f", + "shasum": "" + }, + "require": { + "guzzle/common": "self.version", + "php": ">=5.3.2" + }, + "suggest": { + "guzzle/http": "To convert Guzzle request objects to PHP streams" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.7-dev" + } + }, + "autoload": { + "psr-0": { + "Guzzle\\Stream": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle stream wrapper component", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "Guzzle", + "component", + "stream" + ], + "time": "2013-07-30 22:07:23" }, { "name": "phing/phing", "version": "2.4.14", "source": { "type": "git", - "url": "https://github.com/phingofficial/phing", - "reference": "2.4.14" + "url": "https://github.com/phingofficial/phing.git", + "reference": "41075d93ca254f1c90c79ec7ce81be2b2629e138" }, "dist": { "type": "zip", - "url": "https://github.com/phingofficial/phing/archive/2.4.14.zip", - "reference": "2.4.14", + "url": "https://api.github.com/repos/phingofficial/phing/zipball/41075d93ca254f1c90c79ec7ce81be2b2629e138", + "reference": "41075d93ca254f1c90c79ec7ce81be2b2629e138", "shasum": "" }, "require": { @@ -210,12 +320,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/dbunit.git", - "reference": "1.2.3" + "reference": "8386782a2d55153e44a06eb1a9d13d6ed35d9c2d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/dbunit/zipball/1.2.3", - "reference": "1.2.3", + "url": "https://api.github.com/repos/sebastianbergmann/dbunit/zipball/8386782a2d55153e44a06eb1a9d13d6ed35d9c2d", + "reference": "8386782a2d55153e44a06eb1a9d13d6ed35d9c2d", "shasum": "" }, "require": { @@ -268,12 +378,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "1.2.12" + "reference": "0e9958c459d675fb497d8dc5001c91d335734e48" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/1.2.12", - "reference": "1.2.12", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/0e9958c459d675fb497d8dc5001c91d335734e48", + "reference": "0e9958c459d675fb497d8dc5001c91d335734e48", "shasum": "" }, "require": { @@ -328,13 +438,13 @@ "version": "1.3.3", "source": { "type": "git", - "url": "git://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "1.3.3" + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "16a78140ed2fc01b945cfa539665fadc6a038029" }, "dist": { "type": "zip", - "url": "https://github.com/sebastianbergmann/php-file-iterator/zipball/1.3.3", - "reference": "1.3.3", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/16a78140ed2fc01b945cfa539665fadc6a038029", + "reference": "16a78140ed2fc01b945cfa539665fadc6a038029", "shasum": "" }, "require": { @@ -366,20 +476,20 @@ "filesystem", "iterator" ], - "time": "2012-10-11 04:44:38" + "time": "2012-10-11 11:44:38" }, { "name": "phpunit/php-text-template", "version": "1.1.4", "source": { "type": "git", - "url": "git://github.com/sebastianbergmann/php-text-template.git", - "reference": "1.1.4" + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "5180896f51c5b3648ac946b05f9ec02be78a0b23" }, "dist": { "type": "zip", - "url": "https://github.com/sebastianbergmann/php-text-template/zipball/1.1.4", - "reference": "1.1.4", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5180896f51c5b3648ac946b05f9ec02be78a0b23", + "reference": "5180896f51c5b3648ac946b05f9ec02be78a0b23", "shasum": "" }, "require": { @@ -410,20 +520,20 @@ "keywords": [ "template" ], - "time": "2012-10-31 11:15:28" + "time": "2012-10-31 18:15:28" }, { "name": "phpunit/php-timer", - "version": "1.0.4", + "version": "1.0.5", "source": { "type": "git", - "url": "git://github.com/sebastianbergmann/php-timer.git", - "reference": "1.0.4" + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" }, "dist": { "type": "zip", - "url": "https://github.com/sebastianbergmann/php-timer/zipball/1.0.4", - "reference": "1.0.4", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", "shasum": "" }, "require": { @@ -450,24 +560,24 @@ } ], "description": "Utility class for timing", - "homepage": "http://www.phpunit.de/", + "homepage": "https://github.com/sebastianbergmann/php-timer/", "keywords": [ "timer" ], - "time": "2012-10-11 04:45:58" + "time": "2013-08-02 07:42:54" }, { "name": "phpunit/php-token-stream", - "version": "1.1.5", + "version": "1.2.0", "source": { "type": "git", - "url": "git://github.com/sebastianbergmann/php-token-stream.git", - "reference": "1.1.5" + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "31babf400e5b5868573bf49a000a3519d3978233" }, "dist": { "type": "zip", - "url": "https://github.com/sebastianbergmann/php-token-stream/zipball/1.1.5", - "reference": "1.1.5", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/31babf400e5b5868573bf49a000a3519d3978233", + "reference": "31babf400e5b5868573bf49a000a3519d3978233", "shasum": "" }, "require": { @@ -475,6 +585,11 @@ "php": ">=5.3.3" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2-dev" + } + }, "autoload": { "classmap": [ "PHP/" @@ -495,24 +610,24 @@ } ], "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "http://www.phpunit.de/", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", "keywords": [ "tokenizer" ], - "time": "2012-10-11 04:47:14" + "time": "2013-08-04 05:57:48" }, { "name": "phpunit/phpunit", - "version": "3.7.22", + "version": "3.7.24", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "3.7.22" + "reference": "af7b77ccb5c64458bdfca95665d29558d1df7d08" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3.7.22", - "reference": "3.7.22", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/af7b77ccb5c64458bdfca95665d29558d1df7d08", + "reference": "af7b77ccb5c64458bdfca95665d29558d1df7d08", "shasum": "" }, "require": { @@ -524,7 +639,7 @@ "phpunit/php-code-coverage": "~1.2.1", "phpunit/php-file-iterator": ">=1.3.1", "phpunit/php-text-template": ">=1.1.1", - "phpunit/php-timer": "~1.0.2", + "phpunit/php-timer": ">=1.0.4", "phpunit/phpunit-mock-objects": "~1.2.0", "symfony/yaml": "~2.0" }, @@ -573,20 +688,20 @@ "testing", "xunit" ], - "time": "2013-07-06 06:29:15" + "time": "2013-08-09 06:58:24" }, { "name": "phpunit/phpunit-mock-objects", "version": "1.2.3", "source": { "type": "git", - "url": "git://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "1.2.3" + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875" }, "dist": { "type": "zip", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects/archive/1.2.3.zip", - "reference": "1.2.3", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5794e3c5c5ba0fb037b11d8151add2a07fa82875", + "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875", "shasum": "" }, "require": { @@ -626,34 +741,39 @@ }, { "name": "symfony/browser-kit", - "version": "v2.1.11", + "version": "v2.3.4", "target-dir": "Symfony/Component/BrowserKit", "source": { "type": "git", "url": "https://github.com/symfony/BrowserKit.git", - "reference": "v2.1.11" + "reference": "2639dc4eec81f92760e05396a93bb78000b4f5ca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/BrowserKit/zipball/v2.1.11", - "reference": "v2.1.11", + "url": "https://api.github.com/repos/symfony/BrowserKit/zipball/2639dc4eec81f92760e05396a93bb78000b4f5ca", + "reference": "2639dc4eec81f92760e05396a93bb78000b4f5ca", "shasum": "" }, "require": { "php": ">=5.3.3", - "symfony/dom-crawler": "2.1.*" + "symfony/dom-crawler": "~2.0" }, "require-dev": { - "symfony/css-selector": "2.1.*", - "symfony/process": "2.1.*" + "symfony/css-selector": "~2.0", + "symfony/process": "~2.0" }, "suggest": { - "symfony/process": "2.1.*" + "symfony/process": "" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, "autoload": { "psr-0": { - "Symfony\\Component\\BrowserKit": "" + "Symfony\\Component\\BrowserKit\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -672,30 +792,35 @@ ], "description": "Symfony BrowserKit Component", "homepage": "http://symfony.com", - "time": "2013-04-29 20:22:06" + "time": "2013-07-21 12:12:18" }, { "name": "symfony/css-selector", - "version": "v2.1.11", + "version": "v2.3.4", "target-dir": "Symfony/Component/CssSelector", "source": { "type": "git", "url": "https://github.com/symfony/CssSelector.git", - "reference": "v2.1.11" + "reference": "885544201cb24e79754da1dbd61bd779c2e4353e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/CssSelector/zipball/v2.1.11", - "reference": "v2.1.11", + "url": "https://api.github.com/repos/symfony/CssSelector/zipball/885544201cb24e79754da1dbd61bd779c2e4353e", + "reference": "885544201cb24e79754da1dbd61bd779c2e4353e", "shasum": "" }, "require": { "php": ">=5.3.3" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, "autoload": { "psr-0": { - "Symfony\\Component\\CssSelector": "" + "Symfony\\Component\\CssSelector\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -710,40 +835,49 @@ { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Jean-François Simon", + "email": "jeanfrancois.simon@sensiolabs.com" } ], "description": "Symfony CssSelector Component", "homepage": "http://symfony.com", - "time": "2013-05-17 00:31:34" + "time": "2013-07-21 12:12:18" }, { "name": "symfony/dom-crawler", - "version": "v2.1.11", + "version": "v2.3.4", "target-dir": "Symfony/Component/DomCrawler", "source": { "type": "git", "url": "https://github.com/symfony/DomCrawler.git", - "reference": "v2.1.11" + "reference": "e05e07fe8958a304b5e135f8e65d4ae6148cf59b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/DomCrawler/zipball/v2.1.11", - "reference": "v2.1.11", + "url": "https://api.github.com/repos/symfony/DomCrawler/zipball/e05e07fe8958a304b5e135f8e65d4ae6148cf59b", + "reference": "e05e07fe8958a304b5e135f8e65d4ae6148cf59b", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "symfony/css-selector": "2.1.*" + "symfony/css-selector": "~2.0" }, "suggest": { - "symfony/css-selector": "2.1.*" + "symfony/css-selector": "" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, "autoload": { "psr-0": { - "Symfony\\Component\\DomCrawler": "" + "Symfony\\Component\\DomCrawler\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -762,28 +896,28 @@ ], "description": "Symfony DomCrawler Component", "homepage": "http://symfony.com", - "time": "2013-05-16 00:06:15" + "time": "2013-07-21 12:12:18" }, { "name": "symfony/event-dispatcher", - "version": "v2.3.1", + "version": "v2.3.4", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "v2.3.1" + "reference": "41c9826457c65fa3cf746f214985b7ca9cba42f8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/v2.3.1", - "reference": "v2.3.1", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/41c9826457c65fa3cf746f214985b7ca9cba42f8", + "reference": "41c9826457c65fa3cf746f214985b7ca9cba42f8", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "symfony/dependency-injection": ">=2.0,<3.0" + "symfony/dependency-injection": "~2.0" }, "suggest": { "symfony/dependency-injection": "", @@ -816,30 +950,35 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "http://symfony.com", - "time": "2013-05-13 14:36:40" + "time": "2013-07-21 12:12:18" }, { "name": "symfony/finder", - "version": "v2.1.11", + "version": "v2.3.4", "target-dir": "Symfony/Component/Finder", "source": { "type": "git", "url": "https://github.com/symfony/Finder.git", - "reference": "v2.1.11" + "reference": "4a0fee5b86f5bbd9dfdc11ec124eba2915737ce1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Finder/zipball/v2.1.11", - "reference": "v2.1.11", + "url": "https://api.github.com/repos/symfony/Finder/zipball/4a0fee5b86f5bbd9dfdc11ec124eba2915737ce1", + "reference": "4a0fee5b86f5bbd9dfdc11ec124eba2915737ce1", "shasum": "" }, "require": { "php": ">=5.3.3" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, "autoload": { "psr-0": { - "Symfony\\Component\\Finder": "" + "Symfony\\Component\\Finder\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -858,30 +997,35 @@ ], "description": "Symfony Finder Component", "homepage": "http://symfony.com", - "time": "2013-05-25 15:47:15" + "time": "2013-08-13 20:18:00" }, { "name": "symfony/process", - "version": "v2.1.11", + "version": "v2.3.4", "target-dir": "Symfony/Component/Process", "source": { "type": "git", "url": "https://github.com/symfony/Process.git", - "reference": "v2.1.11" + "reference": "1e91553e1cedd0b8fb1da6ea4f89b02e21713d5b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Process/zipball/v2.1.11", - "reference": "v2.1.11", + "url": "https://api.github.com/repos/symfony/Process/zipball/1e91553e1cedd0b8fb1da6ea4f89b02e21713d5b", + "reference": "1e91553e1cedd0b8fb1da6ea4f89b02e21713d5b", "shasum": "" }, "require": { "php": ">=5.3.3" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, "autoload": { "psr-0": { - "Symfony\\Component\\Process": "" + "Symfony\\Component\\Process\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -900,21 +1044,21 @@ ], "description": "Symfony Process Component", "homepage": "http://symfony.com", - "time": "2013-05-06 10:21:56" + "time": "2013-08-22 06:42:25" }, { "name": "symfony/yaml", - "version": "v2.3.1", + "version": "v2.3.4", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "v2.3.1" + "reference": "5a279f1b5f5e1045a6c432354d9ea727ff3a9847" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/v2.3.1", - "reference": "v2.3.1", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/5a279f1b5f5e1045a6c432354d9ea727ff3a9847", + "reference": "5a279f1b5f5e1045a6c432354d9ea727ff3a9847", "shasum": "" }, "require": { @@ -947,7 +1091,7 @@ ], "description": "Symfony Yaml Component", "homepage": "http://symfony.com", - "time": "2013-05-10 18:12:13" + "time": "2013-08-24 15:26:22" } ], "aliases": [ -- cgit v1.2.1 From 2ccc992da16cf4feaefef3deb230b1b7cae2cac3 Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 6 Sep 2013 12:48:09 -0700 Subject: [ticket/11824] Fix logic PHPBB3-11824 --- phpBB/includes/functions.php | 2 +- phpBB/language/en/acp/board.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 3ff7716edd..2a3157ffbe 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5750,7 +5750,7 @@ function phpbb_get_web_root_path(Request $symfony_request, $phpbb_root_path = '' $corrections = substr_count($path_info, '/'); // We need to account for whether or not app.php is in the URL - if (strpos($symfony_request->server->get('REQUEST_URI', ''), 'app.' . $phpEx) !== false) + if (strpos($symfony_request->server->get('REQUEST_URI', ''), 'app.' . $phpEx . '/') === false) { $corrections -= 1; } diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index 369317e6c9..cde96fe2fd 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -428,8 +428,8 @@ $lang = array_merge($lang, array( 'ICONS_PATH' => 'Post icons storage path', 'ICONS_PATH_EXPLAIN' => 'Path under your phpBB root directory, e.g. images/icons.', 'MOD_REWRITE_ENABLE' => 'Enable URL Rewriting', - 'MOD_REWRITE_ENABLE_EXPLAIN' => 'When disabled, URL paths will include app.php. When enabled, URL paths will not include app.php.
      This option requires the Apache module mod_rewrite to be enabled and the appropriate rewrite rules must be present in .htaccess.', - 'MOD_REWRITE_DISABLED' => 'The mod_rewrite module on your Apache web server is disabled. Enable the module or contact your web hosting provider if you wish to enable this feature.', + 'MOD_REWRITE_ENABLE_EXPLAIN' => 'When disabled, URL paths will include app.php. When enabled, URL paths will not include app.php.
      This option requires the Apache module mod_rewrite to be enabled and the appropriate rewrite rules must be present in .htaccess.', + 'MOD_REWRITE_DISABLED' => 'The mod_rewrite module on your Apache web server is disabled. Enable the module or contact your web hosting provider if you wish to enable this feature.', 'MOD_REWRITE_INFORMATION_UNAVAILABLE' => 'We are unable to determine whether or not this server supports URL rewriting. This setting may be enabled but if URL rewriting is not available, paths generated by this board (such as for use in links) may be broken. Contact your web hosting provider if you are unsure whether or not you can safely enable this feature.', 'PATH_SETTINGS' => 'Path settings', 'RANKS_PATH' => 'Rank image storage path', -- cgit v1.2.1 From bbcd3967efeb270dca27a63e99b2aeb89631790d Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 6 Sep 2013 12:53:34 -0700 Subject: [ticket/11824] Fix smilies PHPBB3-11824 --- phpBB/includes/functions_content.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 05d3c5fde2..104f7b97de 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -813,7 +813,7 @@ function bbcode_nl2br($text) */ function smiley_text($text, $force_option = false) { - global $config, $user, $phpbb_root_path; + global $config, $user, $symfony_request, $phpbb_root_path; if ($force_option || !$config['allow_smilies'] || !$user->optionget('viewsmilies')) { @@ -821,7 +821,7 @@ function smiley_text($text, $force_option = false) } else { - $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path; + $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : phpbb_get_web_root_path($symfony_request, $phpbb_root_path); return preg_replace('# + {S_HIDDEN_FIELDS} @@ -47,23 +47,23 @@ - + - + - + {S_LOGIN_REDIRECT}   - {S_HIDDEN_FIELDS} + {S_HIDDEN_FIELDS} -- cgit v1.2.1 From 0cb4ceabf435499df6648d357d872f5347c8862f Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 9 Sep 2013 11:24:12 -0500 Subject: [ticket/11833] Fix bad template loop PHPBB3-11833 --- phpBB/styles/prosilver/template/mcp_notes_user.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/styles/prosilver/template/mcp_notes_user.html b/phpBB/styles/prosilver/template/mcp_notes_user.html index 1738e45045..eb954fd11d 100644 --- a/phpBB/styles/prosilver/template/mcp_notes_user.html +++ b/phpBB/styles/prosilver/template/mcp_notes_user.html @@ -88,7 +88,7 @@ {L_NO_ENTRIES} - + -- cgit v1.2.1 From 5166240d628e19ba0db13e5dc0de8153e80d4c44 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 9 Sep 2013 11:26:40 -0500 Subject: [ticket/11833] Prevent Twig errors from invalid template loops using BEGINELSE PHPBB3-11833 --- phpBB/phpbb/template/twig/lexer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index 7ab569313c..ba822e7545 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -161,6 +161,9 @@ class phpbb_template_twig_lexer extends Twig_Lexer $subset = trim(substr($matches[2], 1, -1)); // Remove parenthesis $body = $matches[3]; + // Replace + $body = str_replace('', '{% else %}', $body); + // Is the designer wanting to call another loop in a loop? // // @@ -205,9 +208,6 @@ class phpbb_template_twig_lexer extends Twig_Lexer return "{% for {$name} in {$parent}{$name}{$subset} %}{$body}{% endfor %}"; }; - // Replace correctly, only needs to be done once - $code = str_replace('', '{% else %}', $code); - return preg_replace_callback('#(.+?)#s', $callback, $code); } -- cgit v1.2.1 From 07632d46fc730c9b487e7a550ad94d08cb72e27d Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Mon, 9 Sep 2013 20:52:29 +0300 Subject: [ticket/develop/11832] Fix path detection Clean up path, do not count first / PHPBB3-11832 --- phpBB/includes/functions.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 4d2d704a43..7cc3e11129 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5733,6 +5733,8 @@ function phpbb_create_symfony_request(phpbb_request $request) */ function phpbb_get_web_root_path(Request $symfony_request, $phpbb_root_path = '') { + global $phpbb_container; + static $path; if (null !== $path) { @@ -5746,7 +5748,11 @@ function phpbb_get_web_root_path(Request $symfony_request, $phpbb_root_path = '' return $path; } - $corrections = substr_count($path_info, '/'); + $filesystem = $phpbb_container->get('filesystem'); + $path_info = $filesystem->clean_path($path_info); + + // Do not count / at start of path + $corrections = substr_count(substr($path_info, 1), '/'); // When URL Rewriting is enabled, app.php is optional. We have to // correct for it not being there -- cgit v1.2.1 From f30b87519e9ead41525e1979cbce874e8a84e2b8 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 9 Sep 2013 17:28:56 -0500 Subject: [ticket/11832] Inject dependencies for phpbb_get_web_root_path (also moving) Function moved from phpbb_get_web_root_path to filesystem::get_web_root_path PHPBB3-11832 --- phpBB/common.php | 2 +- phpBB/config/services.yml | 2 ++ phpBB/includes/functions.php | 49 ++++--------------------------- phpBB/phpbb/filesystem.php | 69 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 45 deletions(-) (limited to 'phpBB') diff --git a/phpBB/common.php b/phpBB/common.php index a7b7db28ac..cbcd146832 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -47,7 +47,7 @@ if (!defined('PHPBB_INSTALLED')) // Eliminate . and .. from the path require($phpbb_root_path . 'phpbb/filesystem.' . $phpEx); - $phpbb_filesystem = new phpbb_filesystem(); + $phpbb_filesystem = new phpbb_filesystem($phpbb_root_path); $script_path = $phpbb_filesystem->clean_path($script_path); $url = (($secure) ? 'https://' : 'http://') . $server_name; diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 2808e81337..01e470f87f 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -169,6 +169,8 @@ services: filesystem: class: phpbb_filesystem + arguments: + - %core.root_path% groupposition.legend: class: phpbb_groupposition_legend diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 7cc3e11129..844609e4e3 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -7,8 +7,6 @@ * */ -use Symfony\Component\HttpFoundation\Request; - /** * @ignore */ @@ -2413,7 +2411,7 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false) { global $_SID, $_EXTRA_URL, $phpbb_hook; global $phpbb_dispatcher; - global $symfony_request, $phpbb_root_path; + global $symfony_request, $phpbb_root_path, $phpbb_container; if ($params === '' || (is_array($params) && empty($params))) { @@ -2421,7 +2419,8 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false) $params = false; } - $corrected_path = $symfony_request !== null ? phpbb_get_web_root_path($symfony_request, $phpbb_root_path) : ''; + $phpbb_filesystem = $phpbb_container->get('filesystem'); + $corrected_path = $phpbb_filesystem->get_web_root_path($symfony_request); if ($corrected_path) { $url = substr($corrected_path . $url, strlen($phpbb_root_path)); @@ -5218,7 +5217,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 // This path is sent with the base template paths in the assign_vars() // call below. We need to correct it in case we are accessing from a // controller because the web paths will be incorrect otherwise. - $corrected_path = $symfony_request !== null ? phpbb_get_web_root_path($symfony_request, $phpbb_root_path) : ''; + $phpbb_filesystem = $phpbb_container->get('filesystem'); + $corrected_path = $phpbb_filesystem->get_web_root_path($symfony_request); $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $corrected_path; // Send a proper content-language to the output @@ -5725,42 +5725,3 @@ function phpbb_create_symfony_request(phpbb_request $request) $symfony_request = new Request($get_parameters, $post_parameters, array(), $cookie_parameters, $files_parameters, $server_parameters); return $symfony_request; } - -/** -* Get a relative root path from the current URL -* -* @param Request $symfony_request Symfony Request object -*/ -function phpbb_get_web_root_path(Request $symfony_request, $phpbb_root_path = '') -{ - global $phpbb_container; - - static $path; - if (null !== $path) - { - return $path; - } - - $path_info = $symfony_request->getPathInfo(); - if ($path_info === '/') - { - $path = $phpbb_root_path; - return $path; - } - - $filesystem = $phpbb_container->get('filesystem'); - $path_info = $filesystem->clean_path($path_info); - - // Do not count / at start of path - $corrections = substr_count(substr($path_info, 1), '/'); - - // When URL Rewriting is enabled, app.php is optional. We have to - // correct for it not being there - if (strpos($symfony_request->getRequestUri(), $symfony_request->getScriptName()) === false) - { - $corrections -= 1; - } - - $path = $phpbb_root_path . str_repeat('../', $corrections); - return $path; -} diff --git a/phpBB/phpbb/filesystem.php b/phpBB/phpbb/filesystem.php index 27cab48fb0..a85a254865 100644 --- a/phpBB/phpbb/filesystem.php +++ b/phpBB/phpbb/filesystem.php @@ -6,6 +6,9 @@ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ + +use Symfony\Component\HttpFoundation\Request; + /** * @ignore */ @@ -20,6 +23,72 @@ if (!defined('IN_PHPBB')) */ class phpbb_filesystem { + /** @var string */ + protected $phpbb_root_path; + + /** + * Constructor + * + * @param string $phpbb_root_path + */ + public function __construct($phpbb_root_path) + { + $this->phpbb_root_path = $phpbb_root_path; + } + + /** + * Get the phpBB root path + * + * @return string + */ + public function get_phpbb_root_path() + { + return $this->phpbb_root_path; + } + + /** + * Get a relative root path from the current URL + * + * @param Request $symfony_request Symfony Request object + * @return string + */ + function get_web_root_path(Request $symfony_request = null) + { + if ($symfony_request === null) + { + return ''; + } + + static $path; + if (null !== $path) + { + return $path; + } + + $path_info = $symfony_request->getPathInfo(); + if ($path_info === '/') + { + $path = $this->phpbb_root_path; + return $path; + } + + $path_info = $this->clean_path($path_info); + + // Do not count / at start of path + $corrections = substr_count(substr($path_info, 1), '/'); + + // When URL Rewriting is enabled, app.php is optional. We have to + // correct for it not being there + if (strpos($symfony_request->getRequestUri(), $symfony_request->getScriptName()) === false) + { + $corrections -= 1; + } + + $path = $this->phpbb_root_path . str_repeat('../', $corrections); + + return $path; + } + /** * Eliminates useless . and .. components from specified path. * -- cgit v1.2.1 From 6692db892f538d3a72f1dbd06af9a94f24a9da9a Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 9 Sep 2013 18:19:50 -0500 Subject: [ticket/11832] update_web_root_path helper and tests PHPBB3-11832 --- phpBB/includes/functions.php | 7 ++----- phpBB/phpbb/filesystem.php | 34 +++++++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 12 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 844609e4e3..124c0de169 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2419,12 +2419,9 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false) $params = false; } + // Update the root path with the correct relative web path $phpbb_filesystem = $phpbb_container->get('filesystem'); - $corrected_path = $phpbb_filesystem->get_web_root_path($symfony_request); - if ($corrected_path) - { - $url = substr($corrected_path . $url, strlen($phpbb_root_path)); - } + $url = $phpbb_filesystem->update_web_root_path($url, $symfony_request); $append_sid_overwrite = false; diff --git a/phpBB/phpbb/filesystem.php b/phpBB/phpbb/filesystem.php index a85a254865..e8fd03d103 100644 --- a/phpBB/phpbb/filesystem.php +++ b/phpBB/phpbb/filesystem.php @@ -46,17 +46,40 @@ class phpbb_filesystem return $this->phpbb_root_path; } + /** + * Update a path to the correct relative root path + * + * This replaces $phpbb_root_path . some_url with + * get_web_root_path() . some_url OR if $phpbb_root_path + * is not at the beginning of $path, just prepends the + * web root path + * + * @param Request $symfony_request Symfony Request object + * @return string + */ + public function update_web_root_path($path, Request $symfony_request = null) + { + $web_root_path = $this->get_web_root_path($symfony_request); + + if (strpos($path, $this->phpbb_root_path) === 0) + { + $path = substr($path, strlen($this->phpbb_root_path)); + } + + return $web_root_path . $path; + } + /** * Get a relative root path from the current URL * * @param Request $symfony_request Symfony Request object * @return string */ - function get_web_root_path(Request $symfony_request = null) + public function get_web_root_path(Request $symfony_request = null) { if ($symfony_request === null) { - return ''; + return $this->phpbb_root_path; } static $path; @@ -68,8 +91,7 @@ class phpbb_filesystem $path_info = $symfony_request->getPathInfo(); if ($path_info === '/') { - $path = $this->phpbb_root_path; - return $path; + return $path = $this->phpbb_root_path; } $path_info = $this->clean_path($path_info); @@ -84,9 +106,7 @@ class phpbb_filesystem $corrections -= 1; } - $path = $this->phpbb_root_path . str_repeat('../', $corrections); - - return $path; + return $path = $this->phpbb_root_path . str_repeat('../', $corrections); } /** -- cgit v1.2.1 From 38afdd792fd9e5a969a6747391c494cd39e0e2a6 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 10 Sep 2013 02:17:41 +0200 Subject: [prep-release-3.0.12] Remove changelog entry for ticket that was not resolved. A wrong fix version was assigned to PHPBB3-11288. --- phpBB/docs/CHANGELOG.html | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html index 26f1d6ff94..6d8b39d524 100644 --- a/phpBB/docs/CHANGELOG.html +++ b/phpBB/docs/CHANGELOG.html @@ -152,7 +152,6 @@
    • [PHPBB3-11265] - Functional tests do not assert that board installation succeeded
    • [PHPBB3-11269] - Travis functional test case errors
    • [PHPBB3-11278] - Firebird tables are not removed correctly on 3.0.9-rc1 update
    • -
    • [PHPBB3-11288] - Search fooled by hyphens
    • [PHPBB3-11291] - "Could not open input file: ../composer.phar" error during phing's create-package
    • [PHPBB3-11292] - Newlines removed in display of PM reports, no clickable links in PM reports
    • [PHPBB3-11301] - "String offset cast occured" error on PHP 5.4
    • -- cgit v1.2.1 From 3684d8e9711516264fedac0519262891d9894ea1 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Tue, 10 Sep 2013 10:13:26 -0500 Subject: [ticket/11832] Use $phpbb_filesystem instead of the container in append_sid PHPBB3-11832 --- phpBB/includes/functions.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 124c0de169..45f0ae44da 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2409,7 +2409,7 @@ function phpbb_on_page($template, $user, $base_url, $num_items, $per_page, $star */ function append_sid($url, $params = false, $is_amp = true, $session_id = false) { - global $_SID, $_EXTRA_URL, $phpbb_hook; + global $_SID, $_EXTRA_URL, $phpbb_hook, $phpbb_filesystem; global $phpbb_dispatcher; global $symfony_request, $phpbb_root_path, $phpbb_container; @@ -2420,8 +2420,10 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false) } // Update the root path with the correct relative web path - $phpbb_filesystem = $phpbb_container->get('filesystem'); - $url = $phpbb_filesystem->update_web_root_path($url, $symfony_request); + if ($phpbb_filesystem instanceof phpbb_filesystem) + { + $url = $phpbb_filesystem->update_web_root_path($url, $symfony_request); + } $append_sid_overwrite = false; @@ -5719,6 +5721,6 @@ function phpbb_create_symfony_request(phpbb_request $request) array_walk_recursive($get_parameters, $sanitizer); array_walk_recursive($post_parameters, $sanitizer); - $symfony_request = new Request($get_parameters, $post_parameters, array(), $cookie_parameters, $files_parameters, $server_parameters); + $symfony_request = new Symfony\Component\HttpFoundation\Request($get_parameters, $post_parameters, array(), $cookie_parameters, $files_parameters, $server_parameters); return $symfony_request; } -- cgit v1.2.1 From 3a4efa79592616ac099e95d07e9aed52bc5a19a3 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Tue, 10 Sep 2013 11:15:24 -0500 Subject: [ticket/11832] More extensive testing PHPBB3-11832 --- phpBB/phpbb/filesystem.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/filesystem.php b/phpBB/phpbb/filesystem.php index e8fd03d103..6c037b2656 100644 --- a/phpBB/phpbb/filesystem.php +++ b/phpBB/phpbb/filesystem.php @@ -26,6 +26,9 @@ class phpbb_filesystem /** @var string */ protected $phpbb_root_path; + /** @var string */ + protected $web_root_path; + /** * Constructor * @@ -82,16 +85,15 @@ class phpbb_filesystem return $this->phpbb_root_path; } - static $path; - if (null !== $path) + if (null !== $this->web_root_path) { - return $path; + return $this->web_root_path; } $path_info = $symfony_request->getPathInfo(); if ($path_info === '/') { - return $path = $this->phpbb_root_path; + return $this->web_root_path = $this->phpbb_root_path; } $path_info = $this->clean_path($path_info); @@ -106,7 +108,7 @@ class phpbb_filesystem $corrections -= 1; } - return $path = $this->phpbb_root_path . str_repeat('../', $corrections); + return $this->web_root_path = $this->phpbb_root_path . str_repeat('../', $corrections); } /** -- cgit v1.2.1 From 7435c40b5cb99b6be59fbd33cc7df0de24a94379 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Tue, 10 Sep 2013 21:31:19 -0500 Subject: [ticket/11835] Fix ucp_auth_link adding in migration PHPBB3-11835 --- phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php b/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php index 8706d14798..cad1c16bb2 100644 --- a/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php +++ b/phpBB/phpbb/db/migration/data/310/auth_provider_oauth.php @@ -60,7 +60,7 @@ class phpbb_db_migration_data_310_auth_provider_oauth extends phpbb_db_migration return array( array('module.add', array( 'ucp', - 'UCP_AUTH_LINK', + 'UCP_PROFILE', array( 'module_basename' => 'ucp_auth_link', 'modes' => array('auth_link'), -- cgit v1.2.1 From b06c8a80d15c52dd53b12065d5e6e9d56f203ceb Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 12 Sep 2013 10:25:49 -0500 Subject: [ticket/11832] Fix the web path corrections Add some real life examples to test PHPBB3-11832 --- phpBB/phpbb/filesystem.php | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/filesystem.php b/phpBB/phpbb/filesystem.php index 6c037b2656..a2dfab40e5 100644 --- a/phpBB/phpbb/filesystem.php +++ b/phpBB/phpbb/filesystem.php @@ -90,25 +90,49 @@ class phpbb_filesystem return $this->web_root_path; } - $path_info = $symfony_request->getPathInfo(); + // Path info (e.g. /foo/bar) + $path_info = $this->clean_path($symfony_request->getPathInfo()); + + // Full request URI (e.g. phpBB/index.php/foo/bar) + $request_uri = $symfony_request->getRequestUri(); + + // Script name URI (e.g. phpBB/index.php) + $script_name = $symfony_request->getScriptName(); + + /* + * If the path info is empty (single /), then we're not using + * a route like index.php/foo/bar + */ if ($path_info === '/') { return $this->web_root_path = $this->phpbb_root_path; } - $path_info = $this->clean_path($path_info); - - // Do not count / at start of path - $corrections = substr_count(substr($path_info, 1), '/'); + // How many corrections might we need? + $corrections = substr_count($path_info, '/'); - // When URL Rewriting is enabled, app.php is optional. We have to - // correct for it not being there - if (strpos($symfony_request->getRequestUri(), $symfony_request->getScriptName()) === false) + /* + * If the script name (e.g. phpBB/app.php) exists in the + * requestUri (e.g. phpBB/app.php/foo/template), then we + * are have a non-rewritten URL. + */ + if (strpos($request_uri, $script_name) === 0) { - $corrections -= 1; + /* + * Append ../ to the end of the phpbb_root_path as many times + * as / exists in path_info + */ + return $this->web_root_path = $this->phpbb_root_path . str_repeat('../', $corrections); } - return $this->web_root_path = $this->phpbb_root_path . str_repeat('../', $corrections); + /* + * If we're here it means we're at a re-written path, so we must + * correct the relative path for web URLs. We must append ../ + * to the end of the root path as many times as / exists in path_info + * less one time (because the script, e.g. /app.php, doesn't exist in + * the URL) + */ + return $this->web_root_path = $this->phpbb_root_path . str_repeat('../', $corrections - 1); } /** -- cgit v1.2.1 From 946ab9aa75a3b45cc3f6ad17f5a1773bab4fa209 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 12 Sep 2013 11:05:14 -0500 Subject: [ticket/11832] We must instantiate the $phpbb_filesystem in common PHPBB3-11832 --- phpBB/common.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB') diff --git a/phpBB/common.php b/phpBB/common.php index cbcd146832..bfbc5989aa 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -101,6 +101,7 @@ $cache = $phpbb_container->get('cache'); // Instantiate some basic classes $phpbb_dispatcher = $phpbb_container->get('dispatcher'); +$phpbb_filesystem = $phpbb_container->get('filesystem'); $request = $phpbb_container->get('request'); $user = $phpbb_container->get('user'); $auth = $phpbb_container->get('auth'); -- cgit v1.2.1 From 4c00c77739cc20db26d5f87bf26a9a953bc92d3a Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 12 Sep 2013 11:08:40 -0500 Subject: [ticket/11832] Changing comments to say app.php rather than index.php PHPBB3-11832 --- phpBB/phpbb/filesystem.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/filesystem.php b/phpBB/phpbb/filesystem.php index a2dfab40e5..5d70b88a29 100644 --- a/phpBB/phpbb/filesystem.php +++ b/phpBB/phpbb/filesystem.php @@ -93,15 +93,15 @@ class phpbb_filesystem // Path info (e.g. /foo/bar) $path_info = $this->clean_path($symfony_request->getPathInfo()); - // Full request URI (e.g. phpBB/index.php/foo/bar) + // Full request URI (e.g. phpBB/app.php/foo/bar) $request_uri = $symfony_request->getRequestUri(); - // Script name URI (e.g. phpBB/index.php) + // Script name URI (e.g. phpBB/app.php) $script_name = $symfony_request->getScriptName(); /* * If the path info is empty (single /), then we're not using - * a route like index.php/foo/bar + * a route like app.php/foo/bar */ if ($path_info === '/') { -- cgit v1.2.1 From 8e9ee0a4dc04d543a14808e66c253265844f838e Mon Sep 17 00:00:00 2001 From: David King Date: Thu, 12 Sep 2013 09:18:18 -0700 Subject: [ticket/11824] Revert changes to functions_content.php These will be fixed in another PR PHPBB3-11824 --- phpBB/includes/functions_content.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 104f7b97de..05d3c5fde2 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -813,7 +813,7 @@ function bbcode_nl2br($text) */ function smiley_text($text, $force_option = false) { - global $config, $user, $symfony_request, $phpbb_root_path; + global $config, $user, $phpbb_root_path; if ($force_option || !$config['allow_smilies'] || !$user->optionget('viewsmilies')) { @@ -821,7 +821,7 @@ function smiley_text($text, $force_option = false) } else { - $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : phpbb_get_web_root_path($symfony_request, $phpbb_root_path); + $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path; return preg_replace('#session_id)), + 'S_LOGIN_ACTION' => ((!defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("{$phpbb_root_path}{$adm_relative_path}index.$phpEx", false, true, $user->session_id)), 'S_LOGIN_REDIRECT' => build_hidden_fields(array('redirect' => build_url())), 'S_ENABLE_FEEDS' => ($config['feed_enable']) ? true : false, -- cgit v1.2.1 From 8c2f73bb09dc1fa305b59c2adabdc47fd3d5afdb Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 12 Sep 2013 14:15:41 -0500 Subject: [ticket/11828] Fix greedy operators in lexer Use lazy operators and use stricter validation PHPBB3-11828 --- phpBB/phpbb/template/twig/lexer.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index 7ab569313c..bd9ece57fd 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -75,7 +75,7 @@ class phpbb_template_twig_lexer extends Twig_Lexer // Fix tokens that may have inline variables (e.g. "; }; - return preg_replace_callback('##', $callback, $code); + return preg_replace_callback('##', $callback, $code); } /** @@ -264,10 +264,10 @@ class phpbb_template_twig_lexer extends Twig_Lexer */ // Replace #', '{% DEFINE $1 %}', $code); + $code = preg_replace('##', '{% DEFINE $1 %}', $code); // Changing UNDEFINE NAME to DEFINE NAME = null to save from creating an extra token parser/node - $code = preg_replace('##', '{% DEFINE $1= null %}', $code); + $code = preg_replace('##', '{% DEFINE $1= null %}', $code); // Replace all of our variables, {$VARNAME}, with Twig style, {{ definition.VARNAME }} $code = preg_replace('#{\$([a-zA-Z0-9_\.]+)}#', '{{ definition.$1 }}', $code); -- cgit v1.2.1 From 32b92547400c14a402f64463661ce7c1b44e81b3 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 12 Sep 2013 22:59:42 -0500 Subject: [ticket/11745] Correct language, coding guidelines PHPBB3-11745 --- phpBB/language/en/common.php | 2 +- phpBB/phpbb/notification/type/group_request.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 91b1f6d9d9..bd34c51bef 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -415,7 +415,7 @@ $lang = array_merge($lang, array( ), 'NOTIFICATION_BOOKMARK' => '%1$s replied to the topic "%2$s" you have bookmarked.', 'NOTIFICATION_GROUP_REQUEST' => '%1$s is requesting to join the group %2$s.', - 'NOTIFICATION_GROUP_REQUEST_APPROVED' => 'Your request to join the "%1$s" group on has been approved.', + 'NOTIFICATION_GROUP_REQUEST_APPROVED' => 'Your request to join the group %1$s has been approved.', 'NOTIFICATION_PM' => '%1$s sent you a Private Message "%2$s".', 'NOTIFICATION_POST' => '%1$s replied to the topic "%2$s".', 'NOTIFICATION_POST_APPROVED' => 'Your post was approved "%2$s".', diff --git a/phpBB/phpbb/notification/type/group_request.php b/phpBB/phpbb/notification/type/group_request.php index 96015783fb..f3918f381d 100644 --- a/phpBB/phpbb/notification/type/group_request.php +++ b/phpBB/phpbb/notification/type/group_request.php @@ -38,7 +38,8 @@ class phpbb_notification_type_group_request extends phpbb_notification_type_base public function is_available() { // Leader of any groups? - $sql = 'SELECT group_id FROM ' . USER_GROUP_TABLE . ' + $sql = 'SELECT group_id + FROM ' . USER_GROUP_TABLE . ' WHERE user_id = ' . (int) $this->user->data['user_id'] . ' AND group_leader = 1'; $result = $this->db->sql_query_limit($sql, 1); @@ -74,7 +75,8 @@ class phpbb_notification_type_group_request extends phpbb_notification_type_base 'ignore_users' => array(), ), $options); - $sql = 'SELECT user_id FROM ' . USER_GROUP_TABLE . ' + $sql = 'SELECT user_id + FROM ' . USER_GROUP_TABLE . ' WHERE group_leader = 1 AND group_id = ' . (int) $group['group_id']; $result = $this->db->sql_query($sql); -- cgit v1.2.1 From 088dfc120003c2a44f6f8a2de36b39819a5332ab Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 12 Sep 2013 23:32:08 -0500 Subject: [ticket/11727] Fix indentation PHPBB3-11727 --- phpBB/phpbb/template/twig/loader.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/template/twig/loader.php b/phpBB/phpbb/template/twig/loader.php index 997c05f57c..8bf9adfbbe 100644 --- a/phpBB/phpbb/template/twig/loader.php +++ b/phpBB/phpbb/template/twig/loader.php @@ -91,18 +91,18 @@ class phpbb_template_twig_loader extends Twig_Loader_Filesystem * Override for Twig_Loader_Filesystem::findTemplate to add support * for loading from safe directories. */ - protected function findTemplate($name) - { - $name = (string) $name; + protected function findTemplate($name) + { + $name = (string) $name; - // normalize name - $name = preg_replace('#/{2,}#', '/', strtr($name, '\\', '/')); + // normalize name + $name = preg_replace('#/{2,}#', '/', strtr($name, '\\', '/')); // If this is in the cache we can skip the entire process below // as it should have already been validated - if (isset($this->cache[$name])) { - return $this->cache[$name]; - } + if (isset($this->cache[$name])) { + return $this->cache[$name]; + } // First, find the template name. The override above of validateName // causes the validateName process to be skipped for this call @@ -110,7 +110,7 @@ class phpbb_template_twig_loader extends Twig_Loader_Filesystem try { - // Try validating the name (which may throw an exception) + // Try validating the name (which may throw an exception) parent::validateName($name); } catch (Twig_Error_Loader $e) -- cgit v1.2.1 From 288649dd5ee71596637ede27b5c0487f5f737e84 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 12 Sep 2013 23:32:45 -0500 Subject: [ticket/11727] Fix indentation PHPBB3-11727 --- phpBB/phpbb/template/twig/loader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/template/twig/loader.php b/phpBB/phpbb/template/twig/loader.php index 8bf9adfbbe..0829e519f7 100644 --- a/phpBB/phpbb/template/twig/loader.php +++ b/phpBB/phpbb/template/twig/loader.php @@ -110,7 +110,7 @@ class phpbb_template_twig_loader extends Twig_Loader_Filesystem try { - // Try validating the name (which may throw an exception) + // Try validating the name (which may throw an exception) parent::validateName($name); } catch (Twig_Error_Loader $e) -- cgit v1.2.1 From 42884546cc743cc83f8153b7cc889381b0a69077 Mon Sep 17 00:00:00 2001 From: rechosen Date: Fri, 13 Sep 2013 12:05:20 +0200 Subject: [ticket/11843] The twig lexer fixes DEFINE variables with underscores again https://github.com/phpbb/phpbb3/pull/1708 accidentally stopped the twig lexer from fixing DEFINE variables with underscores in them. This commit restores that functionality. PHPBB3-11843 --- phpBB/phpbb/template/twig/lexer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index 8b72a06642..16a693cd7c 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -75,7 +75,7 @@ class phpbb_template_twig_lexer extends Twig_Lexer // Fix tokens that may have inline variables (e.g. + - diff --git a/phpBB/styles/subsilver2/template/overall_footer.html b/phpBB/styles/subsilver2/template/overall_footer.html index d2b30c22a0..348db5d309 100644 --- a/phpBB/styles/subsilver2/template/overall_footer.html +++ b/phpBB/styles/subsilver2/template/overall_footer.html @@ -13,7 +13,7 @@ - + -- cgit v1.2.1 From b7ab068bbc5c58220bc93eb3daffc5642ccba797 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Fri, 13 Sep 2013 11:48:31 -0400 Subject: [ticket/11837] Translate UCP_AUTH_LINK_NOT_SUPPORTED PHPBB3-11837 --- phpBB/language/en/ucp.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB') diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index 0222f92b1b..ac37591266 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -485,6 +485,7 @@ $lang = array_merge($lang, array( 'UCP_AUTH_LINK_ID' => 'Unique identifier', 'UCP_AUTH_LINK_LINK' => 'Link', 'UCP_AUTH_LINK_MANAGE' => 'Manage external account associations', + 'UCP_AUTH_LINK_NOT_SUPPORTED' => 'Linking board accounts to external services is not supported by this board\'s current authentication method.', 'UCP_AUTH_LINK_TITLE' => 'Manage your external account associations', 'UCP_AUTH_LINK_UNLINK' => 'Unlink', 'UCP_COPPA_BEFORE' => 'Before %s', -- cgit v1.2.1 From 0737c4bd6df8209f8b98debcfdb6f0d6def42595 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Fri, 13 Sep 2013 11:53:10 -0400 Subject: [ticket/11836] Fix fatal error on unsupported provider for auth link PHPBB3-11836 --- phpBB/styles/prosilver/template/ucp_auth_link.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/styles/prosilver/template/ucp_auth_link.html b/phpBB/styles/prosilver/template/ucp_auth_link.html index 3c56415db0..078da58d19 100644 --- a/phpBB/styles/prosilver/template/ucp_auth_link.html +++ b/phpBB/styles/prosilver/template/ucp_auth_link.html @@ -6,7 +6,9 @@
      {ERROR}
      - + + +
      -- cgit v1.2.1 From b4a374dc73eda55db1c67b87bd65a73f79411ef5 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 13 Sep 2013 10:58:03 -0500 Subject: [ticket/11832] Fix INCLUDE(JS/CSS) PHPBB3-11832 --- phpBB/common.php | 3 ++- phpBB/config/services.yml | 6 ++--- phpBB/includes/bbcode.php | 4 +-- phpBB/includes/functions.php | 9 ++++++- phpBB/includes/functions_messenger.php | 4 +-- phpBB/install/index.php | 3 ++- phpBB/phpbb/filesystem.php | 33 +++++++++++++++++++++++-- phpBB/phpbb/template/twig/environment.php | 33 +++++++++++++++++++++++-- phpBB/phpbb/template/twig/node/includeasset.php | 2 +- phpBB/phpbb/template/twig/twig.php | 25 +++++++++++-------- 10 files changed, 97 insertions(+), 25 deletions(-) (limited to 'phpBB') diff --git a/phpBB/common.php b/phpBB/common.php index fc309892d6..b9ba37935d 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -51,7 +51,8 @@ if (!defined('PHPBB_INSTALLED')) new phpbb_symfony_request( new phpbb_request() ), - $phpbb_root_path + $phpbb_root_path, + $phpEx ); $script_path = $phpbb_filesystem->clean_path($script_path); diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index a9c819fe9a..9231138e1c 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -172,6 +172,8 @@ services: arguments: - @symfony_request - %core.root_path% + - %core.php_ext% + - %core.adm_relative_path% groupposition.legend: class: phpbb_groupposition_legend @@ -263,13 +265,11 @@ services: template: class: phpbb_template_twig arguments: - - %core.root_path% - - %core.php_ext% + - @filesystem - @config - @user - @template_context - @ext.manager - - %core.adm_relative_path% template_context: class: phpbb_template_context diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index 2fa6a8b099..0c567dd012 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -126,13 +126,13 @@ class bbcode */ function bbcode_cache_init() { - global $phpbb_root_path, $phpEx, $config, $user, $phpbb_extension_manager; + global $phpbb_root_path, $phpEx, $config, $user, $phpbb_extension_manager, $phpbb_filesystem; if (empty($this->template_filename)) { $this->template_bitfield = new bitfield($user->style['bbcode_bitfield']); - $template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context(), $phpbb_extension_manager); + $template = new phpbb_template_twig($phpbb_filesystem, $config, $user, new phpbb_template_context(), $phpbb_extension_manager); $template->set_style(); $template->set_filenames(array('bbcode.html' => 'bbcode.html')); $this->template_filename = $template->get_source_file_for_handle('bbcode.html'); diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index cf9f71244b..b28e808606 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1070,7 +1070,14 @@ function phpbb_clean_path($path) global $phpbb_root_path, $phpEx; require($phpbb_root_path . 'includes/filesystem.' . $phpEx); } - $phpbb_filesystem = new phpbb_filesystem(); + + $phpbb_filesystem = new phpbb_filesystem( + new phpbb_symfony_request( + new phpbb_request() + ), + $phpbb_root_path, + $phpEx + ); } return $phpbb_filesystem->clean_path($path); diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 3bfc1a44f0..13e25b4f5e 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -626,14 +626,14 @@ class messenger */ protected function setup_template() { - global $config, $phpbb_root_path, $phpEx, $user, $phpbb_extension_manager; + global $config, $phpbb_filesystem, $user, $phpbb_extension_manager; if ($this->template instanceof phpbb_template) { return; } - $this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context(), $phpbb_extension_manager); + $this->template = new phpbb_template_twig($phpbb_filesystem, $config, $user, new phpbb_template_context(), $phpbb_extension_manager); } /** diff --git a/phpBB/install/index.php b/phpBB/install/index.php index ec9aa5f32a..fbc47872c8 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -244,7 +244,8 @@ $config = new phpbb_config(array( 'load_tplcompile' => '1' )); -$template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context()); +$phpbb_filesystem = $phpbb_container->get('filesystem'); +$template = new phpbb_template_twig($phpbb_filesystem, $config, $user, new phpbb_template_context()); $paths = array($phpbb_root_path . 'install/update/new/adm/style', $phpbb_admin_path . 'style'); $paths = array_filter($paths, 'is_dir'); $template->set_custom_style('adm', $paths); diff --git a/phpBB/phpbb/filesystem.php b/phpBB/phpbb/filesystem.php index e6c36375af..433fa9a62b 100644 --- a/phpBB/phpbb/filesystem.php +++ b/phpBB/phpbb/filesystem.php @@ -27,6 +27,12 @@ class phpbb_filesystem /** @var string */ protected $phpbb_root_path; + /** @var string */ + protected $adm_relative_path; + + /** @var string */ + protected $php_ext; + /** @var string */ protected $web_root_path; @@ -34,12 +40,15 @@ class phpbb_filesystem * Constructor * * @param phpbb_symfony_request $symfony_request - * @param string $phpbb_root_path + * @param string $phpbb_root_path Relative path to phpBB root + * @param string $php_ext PHP extension (php) */ - public function __construct(phpbb_symfony_request $symfony_request, $phpbb_root_path) + public function __construct(phpbb_symfony_request $symfony_request, $phpbb_root_path, $php_ext, $adm_relative_path = null) { $this->symfony_request = $symfony_request; $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + $this->adm_relative_path = $adm_relative_path; } /** @@ -52,6 +61,26 @@ class phpbb_filesystem return $this->phpbb_root_path; } + /** + * Get the adm root path + * + * @return string + */ + public function get_adm_relative_path() + { + return $this->adm_relative_path; + } + + /** + * Get the php extension + * + * @return string + */ + public function get_php_ext() + { + return $this->php_ext; + } + /** * Update a path to the correct relative root path * diff --git a/phpBB/phpbb/template/twig/environment.php b/phpBB/phpbb/template/twig/environment.php index 9a40dc2b15..612519db69 100644 --- a/phpBB/phpbb/template/twig/environment.php +++ b/phpBB/phpbb/template/twig/environment.php @@ -23,9 +23,15 @@ class phpbb_template_twig_environment extends Twig_Environment /** @var phpbb_config */ protected $phpbb_config; + /** @var phpbb_filesystem */ + protected $phpbb_filesystem; + /** @var string */ protected $phpbb_root_path; + /** @var string */ + protected $web_root_path; + /** @var array **/ protected $namespace_look_up_order = array('__main__'); @@ -38,11 +44,14 @@ class phpbb_template_twig_environment extends Twig_Environment * @param Twig_LoaderInterface $loader * @param array $options Array of options to pass to Twig */ - public function __construct($phpbb_config, $phpbb_extensions, $phpbb_root_path, Twig_LoaderInterface $loader = null, $options = array()) + public function __construct($phpbb_config, $phpbb_extensions, phpbb_filesystem $phpbb_filesystem, Twig_LoaderInterface $loader = null, $options = array()) { $this->phpbb_config = $phpbb_config; $this->phpbb_extensions = $phpbb_extensions; - $this->phpbb_root_path = $phpbb_root_path; + + $this->phpbb_filesystem = $phpbb_filesystem; + $this->phpbb_root_path = $this->phpbb_filesystem->get_phpbb_root_path(); + $this->web_root_path = $this->phpbb_filesystem->get_web_root_path(); return parent::__construct($loader, $options); } @@ -79,6 +88,26 @@ class phpbb_template_twig_environment extends Twig_Environment return $this->phpbb_root_path; } + /** + * Get the web root path + * + * @return string + */ + public function get_web_root_path() + { + return $this->web_root_path; + } + + /** + * Get the phpbb_filesystem object + * + * @return phpbb_filesystem + */ + public function get_filesystem() + { + return $this->phpbb_filesystem; + } + /** * Get the namespace look up order * diff --git a/phpBB/phpbb/template/twig/node/includeasset.php b/phpBB/phpbb/template/twig/node/includeasset.php index 0808e2b10e..2dcd2003a3 100644 --- a/phpBB/phpbb/template/twig/node/includeasset.php +++ b/phpBB/phpbb/template/twig/node/includeasset.php @@ -37,7 +37,7 @@ abstract class phpbb_template_twig_node_includeasset extends Twig_Node ->write("if (substr(\$asset_file, 0, 2) !== './' && \$asset->is_relative()) {\n") ->indent() ->write("\$asset_path = \$asset->get_path();") - ->write("\$local_file = \$this->getEnvironment()->get_phpbb_root_path() . \$asset_path;\n") + ->write("\$local_file = \$this->getEnvironment()->get_web_root_path() . \$asset_path;\n") ->write("if (!file_exists(\$local_file)) {\n") ->indent() ->write("\$local_file = \$this->getEnvironment()->findTemplate(\$asset_path);\n") diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 5746cc64a3..3aa063ffc6 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -30,6 +30,12 @@ class phpbb_template_twig extends phpbb_template_base */ private $cachepath = ''; + /** + * phpBB filesystem + * @var phpbb_filesystem + */ + protected $phpbb_filesystem; + /** * phpBB root path * @var string @@ -71,24 +77,23 @@ class phpbb_template_twig extends phpbb_template_base /** * Constructor. * - * @param string $phpbb_root_path phpBB root path - * @param string $php_ext php extension (typically 'php') + * @param phpbb_filesystem $phpbb_filesystem * @param phpbb_config $config * @param phpbb_user $user * @param phpbb_template_context $context template context * @param phpbb_extension_manager $extension_manager extension manager, if null then template events will not be invoked - * @param string $adm_relative_path relative path to adm directory */ - public function __construct($phpbb_root_path, $php_ext, $config, $user, phpbb_template_context $context, phpbb_extension_manager $extension_manager = null, $adm_relative_path = null) + public function __construct(phpbb_filesystem $phpbb_filesystem, $config, $user, phpbb_template_context $context, phpbb_extension_manager $extension_manager = null) { - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; + $this->phpbb_filesystem = $phpbb_filesystem; + $this->phpbb_root_path = $phpbb_filesystem->get_phpbb_root_path(); + $this->php_ext = $phpbb_filesystem->get_php_ext(); $this->config = $config; $this->user = $user; $this->context = $context; $this->extension_manager = $extension_manager; - $this->cachepath = $phpbb_root_path . 'cache/twig/'; + $this->cachepath = $this->phpbb_root_path . 'cache/twig/'; // Initiate the loader, __main__ namespace paths will be setup later in set_style_names() $loader = new phpbb_template_twig_loader(''); @@ -96,7 +101,7 @@ class phpbb_template_twig extends phpbb_template_base $this->twig = new phpbb_template_twig_environment( $this->config, ($this->extension_manager) ? $this->extension_manager->all_enabled() : array(), - $this->phpbb_root_path, + $this->phpbb_filesystem, $loader, array( 'cache' => (defined('IN_INSTALL')) ? false : $this->cachepath, @@ -118,9 +123,9 @@ class phpbb_template_twig extends phpbb_template_base $this->twig->setLexer($lexer); // Add admin namespace - if ($adm_relative_path !== null && is_dir($this->phpbb_root_path . $adm_relative_path . 'style/')) + if ($this->phpbb_filesystem->get_adm_relative_path() !== null && is_dir($this->phpbb_root_path . $this->phpbb_filesystem->get_adm_relative_path() . 'style/')) { - $this->twig->getLoader()->setPaths($this->phpbb_root_path . $adm_relative_path . 'style/', 'admin'); + $this->twig->getLoader()->setPaths($this->phpbb_root_path . $this->phpbb_filesystem->get_adm_relative_path() . 'style/', 'admin'); } } -- cgit v1.2.1 From 3c6c1ec5f2d8f5d4c2e3f941c0112daa21d97631 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Fri, 13 Sep 2013 16:26:30 -0400 Subject: [ticket/11837] Replace escaped single quote with utf-8 single quote PHPBB3-11837 --- phpBB/language/en/ucp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index ac37591266..e2d5dc5ad1 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -485,7 +485,7 @@ $lang = array_merge($lang, array( 'UCP_AUTH_LINK_ID' => 'Unique identifier', 'UCP_AUTH_LINK_LINK' => 'Link', 'UCP_AUTH_LINK_MANAGE' => 'Manage external account associations', - 'UCP_AUTH_LINK_NOT_SUPPORTED' => 'Linking board accounts to external services is not supported by this board\'s current authentication method.', + 'UCP_AUTH_LINK_NOT_SUPPORTED' => 'Linking board accounts to external services is not supported by this board’s current authentication method.', 'UCP_AUTH_LINK_TITLE' => 'Manage your external account associations', 'UCP_AUTH_LINK_UNLINK' => 'Unlink', 'UCP_COPPA_BEFORE' => 'Before %s', -- cgit v1.2.1 From c8bd2288d1811a766b7c7cea609f7dc013ccd35d Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Fri, 13 Sep 2013 16:34:52 -0400 Subject: [ticket/11836] Fix subsilver fatal error PHPBB3-11836 --- phpBB/styles/subsilver2/template/ucp_auth_link.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/styles/subsilver2/template/ucp_auth_link.html b/phpBB/styles/subsilver2/template/ucp_auth_link.html index c6e4ddd250..75e3133fcf 100644 --- a/phpBB/styles/subsilver2/template/ucp_auth_link.html +++ b/phpBB/styles/subsilver2/template/ucp_auth_link.html @@ -11,7 +11,9 @@ - + + + -- cgit v1.2.1 From 3cd445d055a9236db1476f41b8cadad08f7e5cf7 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 25 Aug 2013 10:11:33 +0300 Subject: [ticket/11811] Remove outline on :focus PHPBB3-11811 --- phpBB/adm/style/admin.css | 10 ++++++++++ phpBB/styles/prosilver/theme/forms.css | 10 ++++++++++ phpBB/styles/subsilver2/theme/stylesheet.css | 3 +++ 3 files changed, 23 insertions(+) (limited to 'phpBB') diff --git a/phpBB/adm/style/admin.css b/phpBB/adm/style/admin.css index b9996fd1d1..a0e14d65a1 100644 --- a/phpBB/adm/style/admin.css +++ b/phpBB/adm/style/admin.css @@ -731,6 +731,10 @@ optgroup, select { color: #000; } +select:focus { + outline-style: none; +} + optgroup { font-size: 1.00em; font-weight: bold; @@ -976,6 +980,7 @@ input:focus, textarea:focus { border: 1px solid #BC2A4D; background-color: #E9E9E2; color: #BC2A4D; + outline-style: none; } /* Submit button fieldset or paragraph @@ -1070,6 +1075,11 @@ input.disabled { color: #666666; } +/* Focus states */ +input.button1:focus, input.button2:focus, input.button3:focus { + outline-style: none; +} + /* Pagination ---------------------------------------- */ .pagination { diff --git a/phpBB/styles/prosilver/theme/forms.css b/phpBB/styles/prosilver/theme/forms.css index 43888733cc..3926da7139 100644 --- a/phpBB/styles/prosilver/theme/forms.css +++ b/phpBB/styles/prosilver/theme/forms.css @@ -29,6 +29,10 @@ select { font-size: 1em; } +select:focus { + outline-style: none; +} + option { padding-right: 1em; } @@ -298,6 +302,7 @@ fieldset.submit-buttons input { .inputbox:focus { border: 1px solid #eaeaea; color: #4b4b4b; + outline-style: none; } input.inputbox { width: 85%; } @@ -369,6 +374,11 @@ input.disabled { color: #666666; } +/* Focus states */ +input.button1:focus, input.button2:focus, input.button3:focus { + outline-style: none; +} + /* Topic and forum Search */ .search-box { margin-top: 3px; diff --git a/phpBB/styles/subsilver2/theme/stylesheet.css b/phpBB/styles/subsilver2/theme/stylesheet.css index abfdf568e7..ec36baa251 100644 --- a/phpBB/styles/subsilver2/theme/stylesheet.css +++ b/phpBB/styles/subsilver2/theme/stylesheet.css @@ -543,6 +543,9 @@ input.radio { border-style: none; } +input:focus, select:focus, textarea:focus { + outline-style: none; +} /* BBCode ------------ */ -- cgit v1.2.1 From 605cd0cafb9cab5f64b1185965d1a354228181e7 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Fri, 16 Aug 2013 18:20:00 +0300 Subject: [ticket/11795] Redo form elements auto-focus Use data-focus attribute for forms to focus elements when document is loaded instead of adding JavaScript PHPBB3-11795 --- phpBB/styles/prosilver/template/forum_fn.js | 17 ++++++++++------- phpBB/styles/prosilver/template/login_body.html | 10 +--------- phpBB/styles/prosilver/template/search_body.html | 10 +--------- 3 files changed, 12 insertions(+), 25 deletions(-) (limited to 'phpBB') diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index 4fb8f7b284..49b3bc5dd9 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -293,20 +293,23 @@ function apply_onkeypress_event() { jQuery(document).ready(apply_onkeypress_event); /** -* Adjust HTML code for IE8 and older versions +* Run onload functions */ (function($) { $(document).ready(function() { + // Focus forms + $('form[data-focus]:first').each(function() { + $('#' + this.getAttribute('data-focus')).focus(); + }); + + // Adjust HTML code for IE8 and older versions var test = document.createElement('div'), oldBrowser = (typeof test.style.borderRadius == 'undefined'); delete test; - if (!oldBrowser) { - return; + if (oldBrowser) { + // Fix .linkslist.bulletin lists + $('ul.linklist.bulletin li:first-child, ul.linklist.bulletin li.rightside:last-child').addClass('no-bulletin'); } - - // Fix .linkslist.bulletin lists - $('ul.linklist.bulletin li:first-child, ul.linklist.bulletin li.rightside:last-child').addClass('no-bulletin'); }); })(jQuery); - diff --git a/phpBB/styles/prosilver/template/login_body.html b/phpBB/styles/prosilver/template/login_body.html index a1c2735ca9..38d9f8c68b 100644 --- a/phpBB/styles/prosilver/template/login_body.html +++ b/phpBB/styles/prosilver/template/login_body.html @@ -1,14 +1,6 @@ - - -
      +
      diff --git a/phpBB/styles/prosilver/template/search_body.html b/phpBB/styles/prosilver/template/search_body.html index fedbdc6642..d4c1f98a2a 100644 --- a/phpBB/styles/prosilver/template/search_body.html +++ b/phpBB/styles/prosilver/template/search_body.html @@ -1,16 +1,8 @@ - -

      {L_SEARCH}

      - +
      -- cgit v1.2.1 From a92a3cfeb97e1d5e506252c09ae545d9382b6bda Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Fri, 16 Aug 2013 18:31:10 +0300 Subject: [ticket/11795] Use data-reset-on-edit attr to reset elements Use data-reset-on-edit attribute to reset other inputs when editing input with data. Do not unbind event (old code unbound it after one use for no reason) PHPBB3-11795 --- phpBB/styles/prosilver/template/forum_fn.js | 5 +++++ .../prosilver/template/ucp_avatar_options_gravatar.html | 16 +--------------- .../prosilver/template/ucp_avatar_options_remote.html | 16 +--------------- 3 files changed, 7 insertions(+), 30 deletions(-) (limited to 'phpBB') diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index 49b3bc5dd9..59c4fd1d80 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -302,6 +302,11 @@ jQuery(document).ready(apply_onkeypress_event); $('#' + this.getAttribute('data-focus')).focus(); }); + // Reset avatar dimensions when changing URL or EMAIL + $('input[data-reset-on-edit]').bind('keyup', function() { + $(this.getAttribute('data-reset-on-edit')).val(''); + }); + // Adjust HTML code for IE8 and older versions var test = document.createElement('div'), oldBrowser = (typeof test.style.borderRadius == 'undefined'); diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options_gravatar.html b/phpBB/styles/prosilver/template/ucp_avatar_options_gravatar.html index 88e0e69f53..b1076c2d14 100644 --- a/phpBB/styles/prosilver/template/ucp_avatar_options_gravatar.html +++ b/phpBB/styles/prosilver/template/ucp_avatar_options_gravatar.html @@ -1,20 +1,6 @@ - -

      {L_GRAVATAR_AVATAR_EMAIL_EXPLAIN}
      -
      +

      {L_GRAVATAR_AVATAR_SIZE_EXPLAIN}
      diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options_remote.html b/phpBB/styles/prosilver/template/ucp_avatar_options_remote.html index 59adf10058..a8f6135fb2 100644 --- a/phpBB/styles/prosilver/template/ucp_avatar_options_remote.html +++ b/phpBB/styles/prosilver/template/ucp_avatar_options_remote.html @@ -1,20 +1,6 @@ - -

      {L_LINK_REMOTE_AVATAR_EXPLAIN}
      -
      +

      {L_LINK_REMOTE_SIZE_EXPLAIN}
      -- cgit v1.2.1 From 253890520d75190aa268c9ea6ce1dd757fb571ff Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Fri, 16 Aug 2013 18:34:05 +0300 Subject: [ticket/11795] Get rid of onload_functions Get rid of onload_functions and onunload_functions Scripts should use $(document).ready() instead PHPBB-11795 --- phpBB/styles/prosilver/template/overall_header.html | 21 --------------------- phpBB/styles/prosilver/template/simple_header.html | 21 --------------------- 2 files changed, 42 deletions(-) (limited to 'phpBB') diff --git a/phpBB/styles/prosilver/template/overall_header.html b/phpBB/styles/prosilver/template/overall_header.html index c1cdc0c223..0c15ec80c7 100644 --- a/phpBB/styles/prosilver/template/overall_header.html +++ b/phpBB/styles/prosilver/template/overall_header.html @@ -30,33 +30,12 @@ var on_page = '{ON_PAGE}'; var per_page = '{PER_PAGE}'; var base_url = '{A_BASE_URL}'; - var onload_functions = new Array(); - var onunload_functions = new Array(); var url = '{UA_POPUP_PM}'; window.open(url.replace(/&/g, '&'), '_phpbbprivmsg', 'height=225,resizable=yes,scrollbars=yes, width=400'); - /** - * New function for handling multiple calls to window.onload and window.unload by pentapenguin - */ - window.onload = function() - { - for (var i = 0; i < onload_functions.length; i++) - { - onload_functions[i](); - } - }; - - window.onunload = function() - { - for (var i = 0; i < onunload_functions.length; i++) - { - onunload_functions[i](); - } - }; - // ]]> diff --git a/phpBB/styles/prosilver/template/simple_header.html b/phpBB/styles/prosilver/template/simple_header.html index 5bdc539f40..9a8c77135e 100644 --- a/phpBB/styles/prosilver/template/simple_header.html +++ b/phpBB/styles/prosilver/template/simple_header.html @@ -14,27 +14,6 @@ var on_page = '{ON_PAGE}'; var per_page = '{PER_PAGE}'; var base_url = '{A_BASE_URL}'; - var onload_functions = new Array(); - var onunload_functions = new Array(); - - /** - * New function for handling multiple calls to window.onload and window.unload by pentapenguin - */ - window.onload = function() - { - for (var i = 0; i < onload_functions.length; i++) - { - onload_functions[i](); - } - } - - window.onunload = function() - { - for (var i = 0; i < onunload_functions.length; i++) - { - onunload_functions[i](); - } - } // ]]> -- cgit v1.2.1 From 4c2aad4ca959d1806c1833a3d4dd141b5c9f50ba Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Fri, 16 Aug 2013 19:20:55 +0300 Subject: [ticket/11795] Get rid of pagination JS variables Move pagination variables to data attributes Replace A_BASE_URL with BASE_URL and use TWIG to escape it PHPBB3-11795 --- phpBB/adm/style/overall_header.html | 2 +- phpBB/adm/style/simple_header.html | 2 +- phpBB/includes/functions.php | 3 +-- phpBB/styles/prosilver/template/forum_fn.js | 20 ++++++++++++++++++-- phpBB/styles/prosilver/template/overall_header.html | 4 ---- phpBB/styles/prosilver/template/pagination.html | 3 ++- phpBB/styles/prosilver/template/simple_header.html | 11 ----------- phpBB/styles/subsilver2/template/overall_header.html | 2 +- 8 files changed, 24 insertions(+), 23 deletions(-) (limited to 'phpBB') diff --git a/phpBB/adm/style/overall_header.html b/phpBB/adm/style/overall_header.html index 8170931221..f76b4c14af 100644 --- a/phpBB/adm/style/overall_header.html +++ b/phpBB/adm/style/overall_header.html @@ -12,7 +12,7 @@ var jump_page = '{LA_JUMP_PAGE}{L_COLON}'; var on_page = '{ON_PAGE}'; var per_page = '{PER_PAGE}'; -var base_url = '{A_BASE_URL}'; +var base_url = '{{ BASE_URL|e('js') }}'; var menu_state = 'shown'; diff --git a/phpBB/adm/style/simple_header.html b/phpBB/adm/style/simple_header.html index 6e0c360600..00ad8f677f 100644 --- a/phpBB/adm/style/simple_header.html +++ b/phpBB/adm/style/simple_header.html @@ -12,7 +12,7 @@ var jump_page = '{LA_JUMP_PAGE}{L_COLON}'; var on_page = '{ON_PAGE}'; var per_page = '{PER_PAGE}'; -var base_url = '{A_BASE_URL}'; +var base_url = '{{ BASE_URL|e('js') }}'; /** * Window popup diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index bf973fe141..70e1cd31fd 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2343,7 +2343,6 @@ function phpbb_generate_template_pagination($template, $base_url, $block_var_nam $template_array = array( $tpl_prefix . 'BASE_URL' => $base_url, - 'A_' . $tpl_prefix . 'BASE_URL' => addslashes($base_url), $tpl_prefix . 'PER_PAGE' => $per_page, 'U_' . $tpl_prefix . 'PREVIOUS_PAGE' => $previous_page, 'U_' . $tpl_prefix . 'NEXT_PAGE' => ($on_page != $total_pages) ? $base_url . $url_delim . $start_name . '=' . ($on_page * $per_page) : '', @@ -2383,7 +2382,7 @@ function phpbb_on_page($template, $user, $base_url, $num_items, $per_page, $star $template->assign_vars(array( 'PER_PAGE' => $per_page, 'ON_PAGE' => $on_page, - 'A_BASE_URL' => addslashes($base_url), + 'BASE_URL' => $base_url, )); return sprintf($user->lang['PAGE_OF'], $on_page, max(ceil($num_items / $per_page), 1)); diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index 59c4fd1d80..992479e45e 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -25,8 +25,19 @@ function popup(url, width, height, name) { /** * Jump to page */ -function jumpto() { - var page = prompt(jump_page, on_page); +function jumpto(item) { + if (!item || !item.length) { + item = $('a.pagination-trigger[data-lang-jump-page]'); + if (!item.length) { + return; + } + } + + var jump_page = item.attr('data-lang-jump-page'), + on_page = item.attr('data-on-page'), + per_page = item.attr('data-per-page'), + base_url = item.attr('data-base-url'), + page = prompt(jump_page, on_page); if (page !== null && !isNaN(page) && page == Math.floor(page) && page > 0) { if (base_url.indexOf('?') === -1) { @@ -307,6 +318,11 @@ jQuery(document).ready(apply_onkeypress_event); $(this.getAttribute('data-reset-on-edit')).val(''); }); + // Pagination + $('a.pagination-trigger').click(function() { + jumpto($(this)); + }); + // Adjust HTML code for IE8 and older versions var test = document.createElement('div'), oldBrowser = (typeof test.style.borderRadius == 'undefined'); diff --git a/phpBB/styles/prosilver/template/overall_header.html b/phpBB/styles/prosilver/template/overall_header.html index 0c15ec80c7..8342136da3 100644 --- a/phpBB/styles/prosilver/template/overall_header.html +++ b/phpBB/styles/prosilver/template/overall_header.html @@ -26,10 +26,6 @@ - diff --git a/phpBB/styles/subsilver2/template/overall_header.html b/phpBB/styles/subsilver2/template/overall_header.html index 02ff1be8d8..5702c62f06 100644 --- a/phpBB/styles/subsilver2/template/overall_header.html +++ b/phpBB/styles/subsilver2/template/overall_header.html @@ -41,7 +41,7 @@ function jumpto() { var page = prompt('{LA_JUMP_PAGE}{L_COLON}', '{ON_PAGE}'); var per_page = '{PER_PAGE}'; - var base_url = '{A_BASE_URL}'; + var base_url = '{{ BASE_URL|e('js') }}'; if (page !== null && !isNaN(page) && page == Math.floor(page) && page > 0) { -- cgit v1.2.1 From 22c8df5403b74cbcad8a267f12c048eaaf053e0f Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Fri, 16 Aug 2013 19:45:38 +0300 Subject: [ticket/11795] Move PM popup JS to forum_fn.js Move PM popup JavaScript from overall_header to forum_fn.js Use TWIG to escape PM popup URL PHPBB3-11795 --- phpBB/includes/functions.php | 1 - phpBB/styles/prosilver/template/forum_fn.js | 6 ++++++ phpBB/styles/prosilver/template/overall_header.html | 17 +++++------------ phpBB/styles/subsilver2/template/overall_header.html | 2 +- 4 files changed, 12 insertions(+), 14 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 70e1cd31fd..888ef59222 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5333,7 +5333,6 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'U_PRIVATEMSGS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=inbox'), 'U_RETURN_INBOX' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=inbox'), 'U_POPUP_PM' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=popup'), - 'UA_POPUP_PM' => addslashes(append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=popup')), 'U_MEMBERLIST' => append_sid("{$phpbb_root_path}memberlist.$phpEx"), 'U_VIEWONLINE' => ($auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) ? append_sid("{$phpbb_root_path}viewonline.$phpEx") : '', 'U_LOGIN_LOGOUT' => $u_login_logout, diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index 992479e45e..4b02093b3e 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -323,6 +323,12 @@ jQuery(document).ready(apply_onkeypress_event); jumpto($(this)); }); + // PM popup + $('body[data-popup-pm-url]').each(function() { + var url = this.getAttribute('data-popup-pm-url'); + window.open(url.replace(/&/g, '&'), '_phpbbprivmsg', 'height=225,resizable=yes,scrollbars=yes, width=400'); + }); + // Adjust HTML code for IE8 and older versions var test = document.createElement('div'), oldBrowser = (typeof test.style.borderRadius == 'undefined'); diff --git a/phpBB/styles/prosilver/template/overall_header.html b/phpBB/styles/prosilver/template/overall_header.html index 8342136da3..26394034d4 100644 --- a/phpBB/styles/prosilver/template/overall_header.html +++ b/phpBB/styles/prosilver/template/overall_header.html @@ -24,17 +24,6 @@ Modified by: --> - - @@ -47,12 +36,16 @@ + + {% set body_attributes %}{{ body_attributes }} data-popup-pm-url="{{ U_POPUP_PM|e('html_attr') }}"{% endset %} + + {$STYLESHEETS} - +
      diff --git a/phpBB/styles/subsilver2/template/overall_header.html b/phpBB/styles/subsilver2/template/overall_header.html index 5702c62f06..a1f69a81a5 100644 --- a/phpBB/styles/subsilver2/template/overall_header.html +++ b/phpBB/styles/subsilver2/template/overall_header.html @@ -23,7 +23,7 @@ - -- cgit v1.2.1 From 0a9ba5415c6ce1f69e50f9a7a77929d7ca0b06b8 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Tue, 27 Aug 2013 12:50:45 +0300 Subject: [ticket/11795] Replace TWIG with phpBB syntax in ACP PHPBB3-11795 --- phpBB/adm/style/overall_header.html | 2 +- phpBB/adm/style/simple_header.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/adm/style/overall_header.html b/phpBB/adm/style/overall_header.html index f76b4c14af..3a9b6db2a3 100644 --- a/phpBB/adm/style/overall_header.html +++ b/phpBB/adm/style/overall_header.html @@ -12,7 +12,7 @@ var jump_page = '{LA_JUMP_PAGE}{L_COLON}'; var on_page = '{ON_PAGE}'; var per_page = '{PER_PAGE}'; -var base_url = '{{ BASE_URL|e('js') }}'; +var base_url = '{BASE_URL|e('js')}'; var menu_state = 'shown'; diff --git a/phpBB/adm/style/simple_header.html b/phpBB/adm/style/simple_header.html index 00ad8f677f..9c4c8a2960 100644 --- a/phpBB/adm/style/simple_header.html +++ b/phpBB/adm/style/simple_header.html @@ -12,7 +12,7 @@ var jump_page = '{LA_JUMP_PAGE}{L_COLON}'; var on_page = '{ON_PAGE}'; var per_page = '{PER_PAGE}'; -var base_url = '{{ BASE_URL|e('js') }}'; +var base_url = '{BASE_URL|e('js')}'; /** * Window popup -- cgit v1.2.1 From e6d87c5bc09e7f3d3813589f99a5e1435f61d517 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Fri, 30 Aug 2013 15:20:14 +0300 Subject: [ticket/11795] Move find user JS to forum_fn Move JavaScript from user search results to forum_fn.js PHPBB3-11795 --- phpBB/styles/prosilver/template/forum_fn.js | 46 ++++++++++++++++++++++ .../styles/prosilver/template/memberlist_body.html | 4 +- .../prosilver/template/memberlist_search.html | 40 ------------------- 3 files changed, 48 insertions(+), 42 deletions(-) (limited to 'phpBB') diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index fc6c418b2e..7b88520f93 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -361,6 +361,52 @@ function im_contact(address) msn_action('im', address); } +/** +* Functions for user search popup +*/ +function insert_user(formId, value) +{ + var form = jQuery(formId), + formName = form.attr('data-form-name'), + fieldName = form.attr('data-field-name'), + item = opener.document.forms[formName][fieldName]; + + if (item.value.length && item.type == 'textarea') { + value = item.value + "\n" + value; + } + + item.value = value; +} + +function insert_marked_users(formId, users) +{ + if (typeof(users.length) == "undefined") + { + if (users.checked) + { + insert_user(formId, users.value); + } + } + else if (users.length > 0) + { + for (i = 0; i < users.length; i++) + { + if (users[i].checked) + { + insert_user(formId, users[i].value); + } + } + } + + self.close(); +} + +function insert_single_user(formId, user) +{ + insert_user(formId, user); + self.close(); +} + /** * Run onload functions */ diff --git a/phpBB/styles/prosilver/template/memberlist_body.html b/phpBB/styles/prosilver/template/memberlist_body.html index 459c3f6bc6..46b35eae2c 100644 --- a/phpBB/styles/prosilver/template/memberlist_body.html +++ b/phpBB/styles/prosilver/template/memberlist_body.html @@ -1,7 +1,7 @@ - + @@ -109,7 +109,7 @@ - {memberrow.RANK_IMG}{memberrow.RANK_TITLE} {memberrow.USERNAME_FULL}
      {L_SELECT} ] + {memberrow.RANK_IMG}{memberrow.RANK_TITLE} {memberrow.USERNAME_FULL}
      {L_SELECT} ] {memberrow.POSTS}{memberrow.POSTS}
      {memberrow.LOCATION}
        {memberrow.JOINED} diff --git a/phpBB/styles/prosilver/template/memberlist_search.html b/phpBB/styles/prosilver/template/memberlist_search.html index f9538ef2e2..0b04d0087c 100644 --- a/phpBB/styles/prosilver/template/memberlist_search.html +++ b/phpBB/styles/prosilver/template/memberlist_search.html @@ -1,43 +1,3 @@ - - - -

      {L_FIND_USERNAME}

      -- cgit v1.2.1 From 973f4bc88731039eca473a08e24684d684f13aef Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Fri, 30 Aug 2013 15:36:17 +0300 Subject: [ticket/11795] Remove outdated comment from forum_fn.js This comment is no longer relevant because function was rewritten PHPBB3-11795 --- phpBB/styles/prosilver/template/forum_fn.js | 2 -- 1 file changed, 2 deletions(-) (limited to 'phpBB') diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index 7b88520f93..8bbb847dfc 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -277,8 +277,6 @@ function phpbb_check_key(event) { /** * Apply onkeypress event for forcing default submit button on ENTER key press -* The jQuery snippet used is based on http://greatwebguy.com/programming/dom/default-html-button-submit-on-enter-with-jquery/ -* The non-jQuery code is a mimick of the jQuery code ;) */ function apply_onkeypress_event() { jQuery('form input[type=text], form input[type=password]').on('keypress', function (e) { -- cgit v1.2.1 From d27bc857f3b8c434696f3324574a9cc10ca9159a Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Fri, 6 Sep 2013 10:17:10 +0300 Subject: [ticket/11795] Remove PM popup PHPBB3-11795 --- phpBB/styles/prosilver/template/forum_fn.js | 6 ------ phpBB/styles/prosilver/template/overall_header.html | 6 +----- phpBB/styles/subsilver2/template/overall_header.html | 3 --- 3 files changed, 1 insertion(+), 14 deletions(-) (limited to 'phpBB') diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index 8bbb847dfc..693211983f 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -425,12 +425,6 @@ function insert_single_user(formId, user) jumpto($(this)); }); - // PM popup - $('body[data-popup-pm-url]').each(function() { - var url = this.getAttribute('data-popup-pm-url'); - window.open(url.replace(/&/g, '&'), '_phpbbprivmsg', 'height=225,resizable=yes,scrollbars=yes, width=400'); - }); - // Adjust HTML code for IE8 and older versions var test = document.createElement('div'), oldBrowser = (typeof test.style.borderRadius == 'undefined'); diff --git a/phpBB/styles/prosilver/template/overall_header.html b/phpBB/styles/prosilver/template/overall_header.html index bc8d9d366a..0b0c7a4172 100644 --- a/phpBB/styles/prosilver/template/overall_header.html +++ b/phpBB/styles/prosilver/template/overall_header.html @@ -36,16 +36,12 @@ - - {% set body_attributes %}{{ body_attributes }} data-popup-pm-url="{U_POPUP_PM|e('html_attr')}"{% endset %} - - {$STYLESHEETS} - +
      diff --git a/phpBB/styles/subsilver2/template/overall_header.html b/phpBB/styles/subsilver2/template/overall_header.html index 4dfde86404..7bfb85017a 100644 --- a/phpBB/styles/subsilver2/template/overall_header.html +++ b/phpBB/styles/subsilver2/template/overall_header.html @@ -22,9 +22,6 @@