diff options
Diffstat (limited to 'phpBB/phpbb')
42 files changed, 280 insertions, 176 deletions
diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 7b71e3c844..902c6ae84c 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -91,6 +91,13 @@ class oauth extends \phpbb\auth\provider\base protected $current_uri; /** + * DI container + * + * @var \Symfony\Component\DependencyInjection\ContainerInterface + */ + protected $phpbb_container; + + /** * phpBB root path * * @var string @@ -116,10 +123,11 @@ class oauth extends \phpbb\auth\provider\base * @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 \Symfony\Component\DependencyInjection\ContainerInterface $phpbb_container DI container * @param string $phpbb_root_path * @param string $php_ext */ - public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\passwords\manager $passwords_manager, \phpbb\request\request_interface $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) + public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\passwords\manager $passwords_manager, \phpbb\request\request_interface $request, \phpbb\user $user, $auth_provider_oauth_token_storage_table, $auth_provider_oauth_token_account_assoc, \phpbb\di\service_collection $service_providers, $users_table, \Symfony\Component\DependencyInjection\ContainerInterface $phpbb_container, $phpbb_root_path, $php_ext) { $this->db = $db; $this->config = $config; @@ -130,6 +138,7 @@ class 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_container = $phpbb_container; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; } @@ -160,7 +169,7 @@ class 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->passwords_manager, $this->request, $this->user, $this->phpbb_root_path, $this->php_ext); + $provider = new \phpbb\auth\provider\db($this->db, $this->config, $this->passwords_manager, $this->request, $this->user, $this->phpbb_container, $this->phpbb_root_path, $this->php_ext); return $provider->login($username, $password); } diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index c3caae5f70..86545c237d 100644 --- a/phpBB/phpbb/console/command/db/migrate.php +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -119,6 +119,7 @@ class migrate extends \phpbb\console\command\command ->core_path('phpbb/db/migration/data/') ->extension_directory('/migrations') ->get_classes(); + $this->migrator->set_migrations($migrations); } diff --git a/phpBB/phpbb/console/command/extension/show.php b/phpBB/phpbb/console/command/extension/show.php index 6ce9607098..f9322034d7 100644 --- a/phpBB/phpbb/console/command/extension/show.php +++ b/phpBB/phpbb/console/command/extension/show.php @@ -37,22 +37,22 @@ class show extends command } $enabled = array_keys($this->manager->all_enabled()); - $this->print_extension_list($output, 'Enabled', $enabled); + $this->print_extension_list($output, $this->user->lang('CLI_EXTENSIONS_ENABLED') . $this->user->lang('COLON'), $enabled); $output->writeln(''); $disabled = array_keys($this->manager->all_disabled()); - $this->print_extension_list($output, 'Disabled', $disabled); + $this->print_extension_list($output, $this->user->lang('CLI_EXTENSIONS_DISABLED') . $this->user->lang('COLON'), $disabled); $output->writeln(''); $purged = array_diff($all, $enabled, $disabled); - $this->print_extension_list($output, 'Available', $purged); + $this->print_extension_list($output, $this->user->lang('CLI_EXTENSIONS_AVAILABLE') . $this->user->lang('COLON'), $purged); } protected function print_extension_list(OutputInterface $output, $type, array $extensions) { - $output->writeln("<info>$type:</info>"); + $output->writeln("<info>$type</info>"); foreach ($extensions as $extension) { diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index dd89d0504a..e2932086db 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -15,6 +15,7 @@ namespace phpbb\controller; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Generator\UrlGenerator; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\RequestContext; /** @@ -44,6 +45,11 @@ class helper protected $symfony_request; /** + * @var \phpbb\filesystem The filesystem object + */ + protected $filesystem; + + /** * phpBB root path * @var string */ @@ -64,15 +70,17 @@ class helper * @param \phpbb\controller\provider $provider Path provider * @param \phpbb\extension\manager $manager Extension manager object * @param \phpbb\symfony_request $symfony_request Symfony Request object + * @param \phpbb\filesystem $filesystem The filesystem object * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP file extension */ - public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, \phpbb\symfony_request $symfony_request, $phpbb_root_path, $php_ext) + public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, \phpbb\symfony_request $symfony_request, \phpbb\filesystem $filesystem, $phpbb_root_path, $php_ext) { $this->template = $template; $this->user = $user; $this->config = $config; $this->symfony_request = $symfony_request; + $this->filesystem = $filesystem; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; $provider->find_routing_files($manager->get_finder()); @@ -108,10 +116,11 @@ class helper * @param string $route Name of the route to travel * @param array $params String or array of additional url parameters * @param bool $is_amp Is url using & (true) or & (false) - * @param string|bool $session_id Possibility to use a custom session id instead of the global one + * @param string|bool $session_id Possibility to use a custom session id instead of the global one + * @param bool|string $reference_type The type of reference to be generated (one of the constants) * @return string The URL already passed through append_sid() */ - public function route($route, array $params = array(), $is_amp = true, $session_id = false) + public function route($route, array $params = array(), $is_amp = true, $session_id = false, $reference_type = UrlGeneratorInterface::ABSOLUTE_PATH) { $anchor = ''; if (isset($params['#'])) @@ -119,27 +128,39 @@ class helper $anchor = '#' . $params['#']; unset($params['#']); } - $url_generator = new UrlGenerator($this->route_collection, new RequestContext()); - $route_url = $url_generator->generate($route, $params); - if (strpos($route_url, '/') === 0) - { - $route_url = substr($route_url, 1); - } + $context = new RequestContext(); + $context->fromRequest($this->symfony_request); + + $script_name = $this->symfony_request->getScriptName(); + $page_name = substr($script_name, -1, 1) == '/' ? '' : utf8_basename($script_name); + + $base_url = $context->getBaseUrl(); + + // If enable_mod_rewrite is false we need to replace the current front-end by app.php, otherwise we need to remove it. + $base_url = str_replace('/' . $page_name, empty($this->config['enable_mod_rewrite']) ? '/app.' . $this->php_ext : '', $base_url); + + // We need to update the base url to move to the directory of the app.php file. + $base_url = str_replace('/app.' . $this->php_ext, '/' . $this->phpbb_root_path . 'app.' . $this->php_ext, $base_url); + + $base_url = $this->filesystem->clean_path($base_url); + + $context->setBaseUrl($base_url); + + $url_generator = new UrlGenerator($this->route_collection, $context); + $route_url = $url_generator->generate($route, $params, $reference_type); if ($is_amp) { $route_url = str_replace(array('&', '&'), array('&', '&'), $route_url); } - // If enable_mod_rewrite is false, we need to include app.php - $route_prefix = $this->phpbb_root_path; - if (empty($this->config['enable_mod_rewrite'])) + if ($reference_type === UrlGeneratorInterface::RELATIVE_PATH && empty($this->config['enable_mod_rewrite'])) { - $route_prefix .= 'app.' . $this->php_ext . '/'; + $route_url = 'app.' . $this->php_ext . '/' . $route_url; } - return append_sid($route_prefix . $route_url . $anchor, false, $is_amp, $session_id); + return append_sid($route_url . $anchor, false, $is_amp, $session_id, true); } /** diff --git a/phpBB/phpbb/controller/provider.php b/phpBB/phpbb/controller/provider.php index fffd4f0428..7e26848290 100644 --- a/phpBB/phpbb/controller/provider.php +++ b/phpBB/phpbb/controller/provider.php @@ -73,7 +73,7 @@ class provider $this->routes = new RouteCollection; foreach ($this->routing_files as $file_path) { - $loader = new YamlFileLoader(new FileLocator($base_path)); + $loader = new YamlFileLoader(new FileLocator(phpbb_realpath($base_path))); $this->routes->addCollection($loader->load($file_path)); } diff --git a/phpBB/phpbb/db/migration/data/v310/notifications_use_full_name.php b/phpBB/phpbb/db/migration/data/v310/notifications_use_full_name.php new file mode 100644 index 0000000000..f749b32119 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/notifications_use_full_name.php @@ -0,0 +1,122 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v310; + +class notifications_use_full_name extends \phpbb\db\migration\migration +{ + protected $notification_types = array( + 'admin_activate_user', + 'approve_post', + 'approve_topic', + 'bookmark', + 'disapprove_post', + 'disapprove_topic', + 'group_request', + 'group_request_approved', + 'pm', + 'post', + 'post_in_queue', + 'quote', + 'report_pm', + 'report_pm_closed', + 'report_post', + 'report_post_closed', + 'topic', + 'topic_in_queue'); + + protected $notification_methods = array( + 'email', + 'jabber', + ); + + static public function depends_on() + { + return array('\phpbb\db\migration\data\v310\rc3'); + } + + public function update_data() + { + return array( + array('custom', array(array($this, 'update_notifications_name'))), + array('custom', array(array($this, 'update_notifications_method_name'))), + ); + } + + public function revert_data() + { + return array( + array('custom', array(array($this, 'revert_notifications_name'))), + array('custom', array(array($this, 'revert_notifications_method_name'))), + ); + } + + public function update_notifications_method_name() + { + foreach ($this->notification_methods as $notification_method) + { + $sql = 'UPDATE ' . USER_NOTIFICATIONS_TABLE . " + SET method = 'notification.method.{$notification_method}' + WHERE method = '{$notification_method}'"; + $this->db->sql_query($sql); + } + } + + public function revert_notifications_method_name() + { + foreach ($this->notification_methods as $notification_method) + { + $sql = 'UPDATE ' . USER_NOTIFICATIONS_TABLE . " + SET method = '{$notification_method}' + WHERE method = 'notification.method.{$notification_method}'"; + $this->db->sql_query($sql); + } + } + + public function update_notifications_name() + { + $sql = 'UPDATE ' . NOTIFICATION_TYPES_TABLE . ' + SET notification_type_enabled = 0 + WHERE ' . $this->db->sql_in_set('notification_type_name', $this->notification_types, true); + $this->db->sql_query($sql); + + foreach ($this->notification_types as $notification_type) + { + $sql = 'UPDATE ' . NOTIFICATION_TYPES_TABLE . " + SET notification_type_name = 'notification.type.{$notification_type}' + WHERE notification_type_name = '{$notification_type}'"; + $this->db->sql_query($sql); + + $sql = 'UPDATE ' . USER_NOTIFICATIONS_TABLE . " + SET item_type = 'notification.type.{$notification_type}' + WHERE item_type = '{$notification_type}'"; + $this->db->sql_query($sql); + } + } + + public function revert_notifications_name() + { + foreach ($this->notification_types as $notification_type) + { + $sql = 'UPDATE ' . NOTIFICATION_TYPES_TABLE . " + SET notification_type_name = '{$notification_type}' + WHERE notification_type_name = 'notification.type.{$notification_type}'"; + $this->db->sql_query($sql); + + $sql = 'UPDATE ' . USER_NOTIFICATIONS_TABLE . " + SET item_type = '{$notification_type}' + WHERE item_type = 'notification.type.{$notification_type}'"; + $this->db->sql_query($sql); + } + } +} diff --git a/phpBB/phpbb/db/migrator.php b/phpBB/phpbb/db/migrator.php index 8bc63e564a..44bea3c5d2 100644 --- a/phpBB/phpbb/db/migrator.php +++ b/phpBB/phpbb/db/migrator.php @@ -715,60 +715,6 @@ class migrator } /** - * Load migration data files from a directory - * - * @param \phpbb\finder $finder - * @param string $path Path to migration data files - * @param bool $check_fulfillable If TRUE (default), we will check - * if all of the migrations are fulfillable after loading them. - * If FALSE, we will not check. You SHOULD check at least once - * to prevent errors (if including multiple directories, check - * with the last call to prevent throwing errors unnecessarily). - * @return array Array of migration names - * @throws \phpbb\db\migration\exception - */ - public function load_migrations(\phpbb\finder $finder, $path, $check_fulfillable = true) - { - if (!is_dir($path)) - { - throw new \phpbb\db\migration\exception('DIRECTORY INVALID', $path); - } - - $migrations = array(); - - $files = $finder - ->extension_directory("/") - ->find_from_paths(array('/' => $path)); - foreach ($files as $file) - { - $migrations[$file['path'] . $file['filename']] = ''; - } - $migrations = $finder->get_classes_from_files($migrations); - - foreach ($migrations as $migration) - { - if (!in_array($migration, $this->migrations)) - { - $this->migrations[] = $migration; - } - } - - if ($check_fulfillable) - { - foreach ($this->migrations as $name) - { - $unfulfillable = $this->unfulfillable($name); - if ($unfulfillable !== false) - { - throw new \phpbb\db\migration\exception('MIGRATION_NOT_FULFILLABLE', $name, $unfulfillable); - } - } - } - - return $this->migrations; - } - - /** * Creates the migrations table if it does not exist. * @return null */ diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index 553b723cc8..638c13e86d 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -15,6 +15,7 @@ namespace phpbb\di; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Dumper\PhpDumper; +use Symfony\Component\HttpKernel\DependencyInjection\RegisterListenersPass; class container_builder { @@ -160,11 +161,13 @@ class container_builder if ($this->use_custom_pass) { + // Symfony Kernel Listeners $this->container->addCompilerPass(new \phpbb\di\pass\collection_pass()); + $this->container->addCompilerPass(new RegisterListenersPass('dispatcher', 'event.listener_listener', 'event.listener')); if ($this->use_kernel_pass) { - $this->container->addCompilerPass(new \phpbb\di\pass\kernel_pass()); + $this->container->addCompilerPass(new RegisterListenersPass('dispatcher')); } } diff --git a/phpBB/phpbb/event/extension_subscriber_loader.php b/phpBB/phpbb/event/extension_subscriber_loader.php deleted file mode 100644 index fc01961e9f..0000000000 --- a/phpBB/phpbb/event/extension_subscriber_loader.php +++ /dev/null @@ -1,39 +0,0 @@ -<?php -/** -* -* This file is part of the phpBB Forum Software package. -* -* @copyright (c) phpBB Limited <https://www.phpbb.com> -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\event; - -use Symfony\Component\EventDispatcher\EventDispatcherInterface; - -class extension_subscriber_loader -{ - private $dispatcher; - private $listener_collection; - - public function __construct(EventDispatcherInterface $dispatcher, \phpbb\di\service_collection $listener_collection) - { - $this->dispatcher = $dispatcher; - $this->listener_collection = $listener_collection; - } - - public function load() - { - if (!empty($this->listener_collection)) - { - foreach ($this->listener_collection as $listener) - { - $this->dispatcher->addSubscriber($listener); - } - } - } -} diff --git a/phpBB/phpbb/extension/base.php b/phpBB/phpbb/extension/base.php index 288fb7d19c..5bb530bad4 100644 --- a/phpBB/phpbb/extension/base.php +++ b/phpBB/phpbb/extension/base.php @@ -35,6 +35,9 @@ class base implements \phpbb\extension\extension_interface /** @var string */ protected $extension_path; + /** @var string[] */ + private $migrations = false; + /** * Constructor * @@ -122,17 +125,16 @@ class base implements \phpbb\extension\extension_interface */ protected function get_migration_file_list() { - static $migrations = false; - - if ($migrations !== false) + if ($this->migrations !== false) { - return $migrations; + return $this->migrations; } // Only have the finder search in this extension path directory $migrations = $this->extension_finder ->extension_directory('/migrations') ->find_from_extension($this->extension_name, $this->extension_path); + $migrations = $this->extension_finder->get_classes_from_files($migrations); return $migrations; diff --git a/phpBB/phpbb/feed/forum.php b/phpBB/phpbb/feed/forum.php index 610b755af3..7a2087c1cd 100644 --- a/phpBB/phpbb/feed/forum.php +++ b/phpBB/phpbb/feed/forum.php @@ -94,7 +94,7 @@ class forum extends \phpbb\feed\post_base WHERE forum_id = ' . $this->forum_id . ' AND topic_moved_id = 0 AND ' . $this->content_visibility->get_visibility_sql('topic', $this->forum_id) . ' - ORDER BY topic_last_post_time DESC'; + ORDER BY topic_last_post_time DESC, topic_last_post_id DESC'; $result = $this->db->sql_query_limit($sql, $this->num_items); $topic_ids = array(); @@ -123,7 +123,7 @@ class forum extends \phpbb\feed\post_base AND ' . $this->content_visibility->get_visibility_sql('post', $this->forum_id, 'p.') . ' AND p.post_time >= ' . $min_post_time . ' AND p.poster_id = u.user_id', - 'ORDER_BY' => 'p.post_time DESC', + 'ORDER_BY' => 'p.post_time DESC, p.post_id DESC', ); return true; diff --git a/phpBB/phpbb/feed/news.php b/phpBB/phpbb/feed/news.php index ea5f4febf5..a02c199d85 100644 --- a/phpBB/phpbb/feed/news.php +++ b/phpBB/phpbb/feed/news.php @@ -99,7 +99,7 @@ class news extends \phpbb\feed\topic_base ), 'WHERE' => 'p.topic_id = t.topic_id AND ' . $this->db->sql_in_set('p.post_id', $post_ids), - 'ORDER_BY' => 'p.post_time DESC', + 'ORDER_BY' => 'p.post_time DESC, p.post_id DESC', ); return true; diff --git a/phpBB/phpbb/feed/overall.php b/phpBB/phpbb/feed/overall.php index f6847c041e..ab452f5386 100644 --- a/phpBB/phpbb/feed/overall.php +++ b/phpBB/phpbb/feed/overall.php @@ -34,7 +34,7 @@ class overall extends \phpbb\feed\post_base FROM ' . TOPICS_TABLE . ' WHERE topic_moved_id = 0 AND ' . $this->content_visibility->get_forums_visibility_sql('topic', $forum_ids) . ' - ORDER BY topic_last_post_time DESC'; + ORDER BY topic_last_post_time DESC, topic_last_post_id DESC'; $result = $this->db->sql_query_limit($sql, $this->num_items); $topic_ids = array(); @@ -71,7 +71,7 @@ class overall extends \phpbb\feed\post_base AND ' . $this->content_visibility->get_forums_visibility_sql('post', $forum_ids, 'p.') . ' AND p.post_time >= ' . $min_post_time . ' AND u.user_id = p.poster_id', - 'ORDER_BY' => 'p.post_time DESC', + 'ORDER_BY' => 'p.post_time DESC, p.post_id DESC', ); return true; diff --git a/phpBB/phpbb/feed/topic.php b/phpBB/phpbb/feed/topic.php index 78e0b4b8ab..66c49e55cf 100644 --- a/phpBB/phpbb/feed/topic.php +++ b/phpBB/phpbb/feed/topic.php @@ -101,7 +101,7 @@ class topic extends \phpbb\feed\post_base 'WHERE' => 'p.topic_id = ' . $this->topic_id . ' AND ' . $this->content_visibility->get_visibility_sql('post', $this->forum_id, 'p.') . ' AND p.poster_id = u.user_id', - 'ORDER_BY' => 'p.post_time DESC', + 'ORDER_BY' => 'p.post_time DESC, p.post_id DESC', ); return true; diff --git a/phpBB/phpbb/feed/topics.php b/phpBB/phpbb/feed/topics.php index 88ca7c33f3..2b9cb3501a 100644 --- a/phpBB/phpbb/feed/topics.php +++ b/phpBB/phpbb/feed/topics.php @@ -71,7 +71,7 @@ class topics extends \phpbb\feed\topic_base ), 'WHERE' => 'p.topic_id = t.topic_id AND ' . $this->db->sql_in_set('p.post_id', $post_ids), - 'ORDER_BY' => 'p.post_time DESC', + 'ORDER_BY' => 'p.post_time DESC, p.post_id DESC', ); return true; diff --git a/phpBB/phpbb/feed/topics_active.php b/phpBB/phpbb/feed/topics_active.php index cde6d36f45..6d5eddfc16 100644 --- a/phpBB/phpbb/feed/topics_active.php +++ b/phpBB/phpbb/feed/topics_active.php @@ -56,7 +56,7 @@ class topics_active extends \phpbb\feed\topic_base WHERE topic_moved_id = 0 AND ' . $this->content_visibility->get_forums_visibility_sql('topic', $in_fid_ary) . ' ' . $last_post_time_sql . ' - ORDER BY topic_last_post_time DESC'; + ORDER BY topic_last_post_time DESC, topic_last_post_id DESC'; $result = $this->db->sql_query_limit($sql, $this->num_items); $post_ids = array(); @@ -88,7 +88,7 @@ class topics_active extends \phpbb\feed\topic_base ), 'WHERE' => 'p.topic_id = t.topic_id AND ' . $this->db->sql_in_set('p.post_id', $post_ids), - 'ORDER_BY' => 'p.post_time DESC', + 'ORDER_BY' => 'p.post_time DESC, p.post_id DESC', ); return true; diff --git a/phpBB/phpbb/mimetype/guesser.php b/phpBB/phpbb/mimetype/guesser.php index 773a1f822a..8baa77089b 100644 --- a/phpBB/phpbb/mimetype/guesser.php +++ b/phpBB/phpbb/mimetype/guesser.php @@ -115,17 +115,42 @@ class guesser return false; } + $mimetype = 'application/octet-stream'; + foreach ($this->guessers as $guesser) { - $mimetype = $guesser->guess($file, $file_name); + $mimetype_guess = $guesser->guess($file, $file_name); - // Try to guess something that is not the fallback application/octet-stream - if ($mimetype !== null && $mimetype !== 'application/octet-stream') - { - return $mimetype; - } + $mimetype = $this->choose_mime_type($mimetype, $mimetype_guess); } // Return any mimetype if we got a result or the fallback value - return (!empty($mimetype)) ? $mimetype : 'application/octet-stream'; + return $mimetype; + } + + /** + * Choose the best mime type based on the current mime type and the guess + * If a guesser returns nulls or application/octet-stream, we will keep + * the current guess. Guesses with a slash inside them will be favored over + * already existing ones. However, any guess that will pass the first check + * will always overwrite the default application/octet-stream. + * + * @param string $mime_type The current mime type + * @param string $guess The current mime type guess + * + * @return string The best mime type based on current mime type and guess + */ + public function choose_mime_type($mime_type, $guess) + { + if ($guess === null || $guess == 'application/octet-stream') + { + return $mime_type; + } + + if ($mime_type == 'application/octet-stream' || strpos($guess, '/') !== false) + { + $mime_type = $guess; + } + + return $mime_type; } } diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php index 5e4bab1530..81b450ebbd 100644 --- a/phpBB/phpbb/notification/manager.php +++ b/phpBB/phpbb/notification/manager.php @@ -570,7 +570,7 @@ class manager { $subscription_methods[$method_name] = array( 'id' => $method->get_type(), - 'lang' => 'NOTIFICATION_METHOD_' . strtoupper($method->get_type()), + 'lang' => str_replace('.', '_', strtoupper($method->get_type())), ); } } @@ -851,8 +851,6 @@ class manager */ public function get_item_type_class($notification_type_name, $data = array()) { - $notification_type_name = (strpos($notification_type_name, 'notification.type.') === 0) ? $notification_type_name : 'notification.type.' . $notification_type_name; - $item = $this->load_object($notification_type_name); $item->set_initial_data($data); @@ -865,8 +863,6 @@ class manager */ public function get_method_class($method_name) { - $method_name = (strpos($method_name, 'notification.method.') === 0) ? $method_name : 'notification.method.' . $method_name; - return $this->load_object($method_name); } diff --git a/phpBB/phpbb/notification/method/email.php b/phpBB/phpbb/notification/method/email.php index 424f0aaf57..a4b93bc85c 100644 --- a/phpBB/phpbb/notification/method/email.php +++ b/phpBB/phpbb/notification/method/email.php @@ -27,7 +27,7 @@ class email extends \phpbb\notification\method\messenger_base */ public function get_type() { - return 'email'; + return 'notification.method.email'; } /** diff --git a/phpBB/phpbb/notification/method/jabber.php b/phpBB/phpbb/notification/method/jabber.php index 55de50fecd..09f186e3ca 100644 --- a/phpBB/phpbb/notification/method/jabber.php +++ b/phpBB/phpbb/notification/method/jabber.php @@ -27,7 +27,7 @@ class jabber extends \phpbb\notification\method\messenger_base */ public function get_type() { - return 'jabber'; + return 'notification.method.jabber'; } /** diff --git a/phpBB/phpbb/notification/type/admin_activate_user.php b/phpBB/phpbb/notification/type/admin_activate_user.php index 364df74cc5..038ca3726e 100644 --- a/phpBB/phpbb/notification/type/admin_activate_user.php +++ b/phpBB/phpbb/notification/type/admin_activate_user.php @@ -25,7 +25,7 @@ class admin_activate_user extends \phpbb\notification\type\base */ public function get_type() { - return 'admin_activate_user'; + return 'notification.type.admin_activate_user'; } /** diff --git a/phpBB/phpbb/notification/type/approve_post.php b/phpBB/phpbb/notification/type/approve_post.php index 22c9076adc..a9e635b41a 100644 --- a/phpBB/phpbb/notification/type/approve_post.php +++ b/phpBB/phpbb/notification/type/approve_post.php @@ -27,7 +27,7 @@ class approve_post extends \phpbb\notification\type\post */ public function get_type() { - return 'approve_post'; + return 'notification.type.approve_post'; } /** diff --git a/phpBB/phpbb/notification/type/approve_topic.php b/phpBB/phpbb/notification/type/approve_topic.php index 77e53a0064..2f4678359c 100644 --- a/phpBB/phpbb/notification/type/approve_topic.php +++ b/phpBB/phpbb/notification/type/approve_topic.php @@ -27,7 +27,7 @@ class approve_topic extends \phpbb\notification\type\topic */ public function get_type() { - return 'approve_topic'; + return 'notification.type.approve_topic'; } /** diff --git a/phpBB/phpbb/notification/type/bookmark.php b/phpBB/phpbb/notification/type/bookmark.php index 21180b3b53..4f2d34cb60 100644 --- a/phpBB/phpbb/notification/type/bookmark.php +++ b/phpBB/phpbb/notification/type/bookmark.php @@ -27,7 +27,7 @@ class bookmark extends \phpbb\notification\type\post */ public function get_type() { - return 'bookmark'; + return 'notification.type.bookmark'; } /** diff --git a/phpBB/phpbb/notification/type/disapprove_post.php b/phpBB/phpbb/notification/type/disapprove_post.php index 7b18ed70ea..6c7bcbcaee 100644 --- a/phpBB/phpbb/notification/type/disapprove_post.php +++ b/phpBB/phpbb/notification/type/disapprove_post.php @@ -27,7 +27,7 @@ class disapprove_post extends \phpbb\notification\type\approve_post */ public function get_type() { - return 'disapprove_post'; + return 'notification.type.disapprove_post'; } /** diff --git a/phpBB/phpbb/notification/type/disapprove_topic.php b/phpBB/phpbb/notification/type/disapprove_topic.php index 3f87741807..efa5eb7ecd 100644 --- a/phpBB/phpbb/notification/type/disapprove_topic.php +++ b/phpBB/phpbb/notification/type/disapprove_topic.php @@ -27,7 +27,7 @@ class disapprove_topic extends \phpbb\notification\type\approve_topic */ public function get_type() { - return 'disapprove_topic'; + return 'notification.type.disapprove_topic'; } /** diff --git a/phpBB/phpbb/notification/type/group_request.php b/phpBB/phpbb/notification/type/group_request.php index 980234c129..4baf516fed 100644 --- a/phpBB/phpbb/notification/type/group_request.php +++ b/phpBB/phpbb/notification/type/group_request.php @@ -20,7 +20,7 @@ class group_request extends \phpbb\notification\type\base */ public function get_type() { - return 'group_request'; + return 'notification.type.group_request'; } /** diff --git a/phpBB/phpbb/notification/type/group_request_approved.php b/phpBB/phpbb/notification/type/group_request_approved.php index bf9cd0019f..d284046ffa 100644 --- a/phpBB/phpbb/notification/type/group_request_approved.php +++ b/phpBB/phpbb/notification/type/group_request_approved.php @@ -20,7 +20,7 @@ class group_request_approved extends \phpbb\notification\type\base */ public function get_type() { - return 'group_request_approved'; + return 'notification.type.group_request_approved'; } /** diff --git a/phpBB/phpbb/notification/type/pm.php b/phpBB/phpbb/notification/type/pm.php index 8445ca4b22..330a70c85a 100644 --- a/phpBB/phpbb/notification/type/pm.php +++ b/phpBB/phpbb/notification/type/pm.php @@ -27,7 +27,7 @@ class pm extends \phpbb\notification\type\base */ public function get_type() { - return 'pm'; + return 'notification.type.pm'; } /** diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php index 1eba4a6a88..d9e74f2e95 100644 --- a/phpBB/phpbb/notification/type/post.php +++ b/phpBB/phpbb/notification/type/post.php @@ -27,7 +27,7 @@ class post extends \phpbb\notification\type\base */ public function get_type() { - return 'post'; + return 'notification.type.post'; } /** diff --git a/phpBB/phpbb/notification/type/post_in_queue.php b/phpBB/phpbb/notification/type/post_in_queue.php index 3bb1028619..315b8b0243 100644 --- a/phpBB/phpbb/notification/type/post_in_queue.php +++ b/phpBB/phpbb/notification/type/post_in_queue.php @@ -27,7 +27,7 @@ class post_in_queue extends \phpbb\notification\type\post */ public function get_type() { - return 'post_in_queue'; + return 'notification.type.post_in_queue'; } /** @@ -44,7 +44,7 @@ class post_in_queue extends \phpbb\notification\type\post * Array of data (including keys 'id', 'lang', and 'group') */ public static $notification_option = array( - 'id' => 'needs_approval', + 'id' => 'notification.type.needs_approval', 'lang' => 'NOTIFICATION_TYPE_IN_MODERATION_QUEUE', 'group' => 'NOTIFICATION_GROUP_MODERATION', ); diff --git a/phpBB/phpbb/notification/type/quote.php b/phpBB/phpbb/notification/type/quote.php index 5c3c822ec2..508ca92fa0 100644 --- a/phpBB/phpbb/notification/type/quote.php +++ b/phpBB/phpbb/notification/type/quote.php @@ -27,7 +27,7 @@ class quote extends \phpbb\notification\type\post */ public function get_type() { - return 'quote'; + return 'notification.type.quote'; } /** diff --git a/phpBB/phpbb/notification/type/report_pm.php b/phpBB/phpbb/notification/type/report_pm.php index 14a328e104..d39143f4b7 100644 --- a/phpBB/phpbb/notification/type/report_pm.php +++ b/phpBB/phpbb/notification/type/report_pm.php @@ -27,7 +27,7 @@ class report_pm extends \phpbb\notification\type\pm */ public function get_type() { - return 'report_pm'; + return 'notification.type.report_pm'; } /** @@ -61,7 +61,7 @@ class report_pm extends \phpbb\notification\type\pm * Array of data (including keys 'id', 'lang', and 'group') */ public static $notification_option = array( - 'id' => 'report', + 'id' => 'notification.type.report', 'lang' => 'NOTIFICATION_TYPE_REPORT', 'group' => 'NOTIFICATION_GROUP_MODERATION', ); diff --git a/phpBB/phpbb/notification/type/report_pm_closed.php b/phpBB/phpbb/notification/type/report_pm_closed.php index de7bf74a97..9f301ee2cc 100644 --- a/phpBB/phpbb/notification/type/report_pm_closed.php +++ b/phpBB/phpbb/notification/type/report_pm_closed.php @@ -27,7 +27,7 @@ class report_pm_closed extends \phpbb\notification\type\pm */ public function get_type() { - return 'report_pm_closed'; + return 'notification.type.report_pm_closed'; } /** diff --git a/phpBB/phpbb/notification/type/report_post.php b/phpBB/phpbb/notification/type/report_post.php index bec59df9d5..027cca716b 100644 --- a/phpBB/phpbb/notification/type/report_post.php +++ b/phpBB/phpbb/notification/type/report_post.php @@ -26,7 +26,7 @@ class report_post extends \phpbb\notification\type\post_in_queue */ public function get_type() { - return 'report_post'; + return 'notification.type.report_post'; } /** @@ -67,7 +67,7 @@ class report_post extends \phpbb\notification\type\post_in_queue * Array of data (including keys 'id' and 'lang') */ public static $notification_option = array( - 'id' => 'report', + 'id' => 'notification.type.report', 'lang' => 'NOTIFICATION_TYPE_REPORT', 'group' => 'NOTIFICATION_GROUP_MODERATION', ); diff --git a/phpBB/phpbb/notification/type/report_post_closed.php b/phpBB/phpbb/notification/type/report_post_closed.php index cd1400f8fa..a0bb187a0d 100644 --- a/phpBB/phpbb/notification/type/report_post_closed.php +++ b/phpBB/phpbb/notification/type/report_post_closed.php @@ -27,7 +27,7 @@ class report_post_closed extends \phpbb\notification\type\post */ public function get_type() { - return 'report_post_closed'; + return 'notification.type.report_post_closed'; } /** diff --git a/phpBB/phpbb/notification/type/topic.php b/phpBB/phpbb/notification/type/topic.php index af199fb765..cf0ec77099 100644 --- a/phpBB/phpbb/notification/type/topic.php +++ b/phpBB/phpbb/notification/type/topic.php @@ -27,7 +27,7 @@ class topic extends \phpbb\notification\type\base */ public function get_type() { - return 'topic'; + return 'notification.type.topic'; } /** diff --git a/phpBB/phpbb/notification/type/topic_in_queue.php b/phpBB/phpbb/notification/type/topic_in_queue.php index aef1487d77..4c60c6b858 100644 --- a/phpBB/phpbb/notification/type/topic_in_queue.php +++ b/phpBB/phpbb/notification/type/topic_in_queue.php @@ -27,7 +27,7 @@ class topic_in_queue extends \phpbb\notification\type\topic */ public function get_type() { - return 'topic_in_queue'; + return 'notification.type.topic_in_queue'; } /** @@ -44,7 +44,7 @@ class topic_in_queue extends \phpbb\notification\type\topic * Array of data (including keys 'id', 'lang', and 'group') */ public static $notification_option = array( - 'id' => 'needs_approval', + 'id' => 'notification.type.needs_approval', 'lang' => 'NOTIFICATION_TYPE_IN_MODERATION_QUEUE', 'group' => 'NOTIFICATION_GROUP_MODERATION', ); diff --git a/phpBB/phpbb/path_helper.php b/phpBB/phpbb/path_helper.php index 38dbbab51e..936564d8b6 100644 --- a/phpBB/phpbb/path_helper.php +++ b/phpBB/phpbb/path_helper.php @@ -316,7 +316,7 @@ class path_helper * Glue URL parameters together * * @param array $params URL parameters in the form of array(name => value) - * @return string Returns the glued string, e.g. name1=value1&name2=value2 + * @return string Returns the glued string, e.g. name1=value1&name2&name3=value3 */ public function glue_url_params($params) { @@ -324,7 +324,15 @@ class path_helper foreach ($params as $key => $value) { - $_params[] = $key . '=' . $value; + // some parameters do not have value + if ($value !== null) + { + $_params[] = $key . '=' . $value; + } + else + { + $_params[] = $key; + } } return implode('&', $_params); } @@ -353,7 +361,17 @@ class path_helper { continue; } - list($key, $value) = explode('=', $argument, 2); + + // some parameters don't have value + if (strpos($argument, '=') !== false) + { + list($key, $value) = explode('=', $argument, 2); + } + else + { + $key = $argument; + $value = null; + } if ($key === '') { diff --git a/phpBB/phpbb/profilefields/manager.php b/phpBB/phpbb/profilefields/manager.php index 98802d2209..4ad3214ae4 100644 --- a/phpBB/phpbb/profilefields/manager.php +++ b/phpBB/phpbb/profilefields/manager.php @@ -245,12 +245,8 @@ class manager $cp_data = $this->build_insert_sql_array($cp_data); $cp_data['user_id'] = (int) $user_id; - $this->db->sql_return_on_error(true); - $sql = 'INSERT INTO ' . $this->fields_data_table . ' ' . $this->db->sql_build_array('INSERT', $cp_data); $this->db->sql_query($sql); - - $this->db->sql_return_on_error(false); } } @@ -328,7 +324,7 @@ class manager * Event to modify profile fields data retrieved from the database * * @event core.grab_profile_fields_data - * @var array user_ids Single user id or an array of ids + * @var array user_ids Single user id or an array of ids * @var array field_data Array with profile fields data * @since 3.1.0-b3 */ @@ -377,7 +373,7 @@ class manager * Event to modify data of the generated profile fields, before the template assignment loop * * @event core.generate_profile_fields_template_data_before - * @var array profile_row Array with users profile field data + * @var array profile_row Array with users profile field data * @var array tpl_fields Array with template data fields * @var bool use_contact_fields Should we display contact fields as such? * @since 3.1.0-b3 @@ -445,7 +441,7 @@ class manager * Event to modify template data of the generated profile fields * * @event core.generate_profile_fields_template_data - * @var array profile_row Array with users profile field data + * @var array profile_row Array with users profile field data * @var array tpl_fields Array with template data fields * @var bool use_contact_fields Should we display contact fields as such? * @since 3.1.0-b3 diff --git a/phpBB/phpbb/session.php b/phpBB/phpbb/session.php index 7d564742af..30b364821d 100644 --- a/phpBB/phpbb/session.php +++ b/phpBB/phpbb/session.php @@ -441,8 +441,8 @@ class session if (!$session_expired) { - // Only update session DB a minute or so after last update or if page changes - if ($this->time_now - $this->data['session_time'] > 60 || ($this->update_session_page && $this->data['session_page'] != $this->page['page'])) + // Only update session DB a minute or so after last update or if page changes and is not ajax request + if (($this->time_now - $this->data['session_time'] > 60 || ($this->update_session_page && $this->data['session_page'] != $this->page['page'])) && !$request->is_ajax()) { $sql_ary = array('session_time' => $this->time_now); diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 5e2057f818..a3b002f350 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -177,6 +177,10 @@ class twig extends \phpbb\template\base } $names = $this->get_user_style(); + // Add 'all' folder to $names array + // It allows extensions to load a template file from 'all' folder, + // if a style doesn't include it. + $names[] = 'all'; $paths = array(); foreach ($style_directories as $directory) |