From e4488fe78819b5dd7b1e7edd8c8defe07d264b37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=A8rejean?= Date: Wed, 15 Dec 2010 09:39:28 +0100 Subject: [PATCH 001/170] [ticket/9948] Inline quicktime files won't show When attaching a quicktime file and placing it inline the movie won't be shown due to the size the movie box is being given. PHPBB3-9948 --- phpBB/styles/prosilver/template/attachment.html | 4 ++-- phpBB/styles/subsilver2/template/attachment.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/styles/prosilver/template/attachment.html b/phpBB/styles/prosilver/template/attachment.html index cc5aacff2f..4c0a326f1e 100644 --- a/phpBB/styles/prosilver/template/attachment.html +++ b/phpBB/styles/prosilver/template/attachment.html @@ -70,12 +70,12 @@ - + - + diff --git a/phpBB/styles/subsilver2/template/attachment.html b/phpBB/styles/subsilver2/template/attachment.html index 833bd4d55f..b5b547b2e6 100644 --- a/phpBB/styles/subsilver2/template/attachment.html +++ b/phpBB/styles/subsilver2/template/attachment.html @@ -67,12 +67,12 @@ - + - + From 8a07e8a4f8092e0123f16e9b4acf15d7d54d4c24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=A8rejean?= Date: Tue, 21 Dec 2010 15:08:07 +0100 Subject: [PATCH 002/170] [ticket/9954] Remove unneeded never permission The `ROLE_USER_NOAVATAR` role gets a *never* permission assigned for the two "u_masspm*" permissions. Due to this, this role changes behaviour it isn't intended to change. It should assign "no" as is done in the `ROLE_USER_LIMITED` role. PHPBB3-9954 --- phpBB/install/schemas/schema_data.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 355af802ef..700d4d63d1 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -565,7 +565,7 @@ INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT # No Avatar (u_) INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 9, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option NOT IN ('u_attach', 'u_chgavatar', 'u_viewonline', 'u_chggrp', 'u_chgname', 'u_ignoreflood', 'u_pm_attach', 'u_pm_emailpm', 'u_pm_flash', 'u_savedrafts', 'u_search', 'u_sendemail', 'u_sendim', 'u_masspm', 'u_masspm_group'); -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 9, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_chgavatar', 'u_masspm', 'u_masspm_group'); +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 9, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_chgavatar'); # Full Moderator (m_) INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 10, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'm_%'; From 6a7c85382828dc95b5190ab6dde5ae25149e6025 Mon Sep 17 00:00:00 2001 From: Raimon Date: Fri, 7 Jan 2011 23:47:17 +0100 Subject: [PATCH 003/170] [ticket/9980] URLs to javascript should be T_SUPER_TEMPLATE_PATH instead of T_TEMPLATE_PATH PHPBB3-9980 --- phpBB/styles/prosilver/template/memberlist_search.html | 2 +- phpBB/styles/prosilver/template/overall_header.html | 4 ++-- phpBB/styles/prosilver/template/posting_buttons.html | 2 +- phpBB/styles/prosilver/template/posting_smilies.html | 2 +- phpBB/styles/prosilver/template/simple_header.html | 4 ++-- phpBB/styles/subsilver2/template/posting_buttons.html | 2 +- phpBB/styles/subsilver2/template/posting_smilies.html | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/phpBB/styles/prosilver/template/memberlist_search.html b/phpBB/styles/prosilver/template/memberlist_search.html index b95185a6f2..9df648f644 100644 --- a/phpBB/styles/prosilver/template/memberlist_search.html +++ b/phpBB/styles/prosilver/template/memberlist_search.html @@ -37,7 +37,7 @@ function insert_single(user) } // ]]> - +

{L_FIND_USERNAME}

diff --git a/phpBB/styles/prosilver/template/overall_header.html b/phpBB/styles/prosilver/template/overall_header.html index 44857dbc41..e607b6f489 100644 --- a/phpBB/styles/prosilver/template/overall_header.html +++ b/phpBB/styles/prosilver/template/overall_header.html @@ -85,8 +85,8 @@ // ]]> - - + + diff --git a/phpBB/styles/prosilver/template/posting_buttons.html b/phpBB/styles/prosilver/template/posting_buttons.html index 5d21229611..19d55d1a4a 100644 --- a/phpBB/styles/prosilver/template/posting_buttons.html +++ b/phpBB/styles/prosilver/template/posting_buttons.html @@ -38,7 +38,7 @@ // ]]> - + diff --git a/phpBB/includes/acm/acm_redis.php b/phpBB/includes/acm/acm_redis.php new file mode 100644 index 0000000000..3f0e590d0a --- /dev/null +++ b/phpBB/includes/acm/acm_redis.php @@ -0,0 +1,142 @@ +extension}] for the ACM module $acm_type.", E_USER_ERROR); + } + + $this->redis = new Redis(); + foreach (explode(',', PHPBB_ACM_REDIS) as $u) + { + $parts = explode('/', $u); + $this->redis->connect(trim($parts[0]), trim($parts[1])); + } + + if (defined('PHPBB_ACM_REDIS_PASSWORD')) + { + if (!$this->redis->auth(PHPBB_ACM_REDIS_PASSWORD)) + { + trigger_error("Incorrect password for the ACM module $acm_type.", E_USER_ERROR); + } + } + } + + /** + * Unload the cache resources + * + * @return void + */ + function unload() + { + parent::unload(); + + $this->redis->close(); + } + + /** + * Purge cache data + * + * @return void + */ + function purge() + { + $this->redis->flushDB(); + + parent::purge(); + } + + /** + * Fetch an item from the cache + * + * @access protected + * @param string $var Cache key + * @return mixed Cached data + */ + function _read($var) + { + return $this->redis->get($this->key_prefix . $var); + } + + /** + * Store data in the cache + * + * @access protected + * @param string $var Cache key + * @param mixed $data Data to store + * @param int $ttl Time-to-live of cached data + * @return bool True if the operation succeeded + */ + function _write($var, $data, $ttl = 2592000) + { + return $this->redis->setex($this->key_prefix . $var, $ttl, $data); + } + + /** + * Remove an item from the cache + * + * @access protected + * @param string $var Cache key + * @return bool True if the operation succeeded + */ + function _delete($var) + { + if ($this->redis->delete($this->key_prefix . $var) > 0) + { + return true; + } + return false; + } +} From f18d93756cad336db8299a2ab88ec3382efe171a Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 28 Mar 2011 23:09:32 +0800 Subject: [PATCH 120/170] [ticket/10110] Update comments with a link to the phpredis extension PHPBB3-10110 --- phpBB/includes/acm/acm_redis.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/acm/acm_redis.php b/phpBB/includes/acm/acm_redis.php index 3f0e590d0a..b1739c0479 100644 --- a/phpBB/includes/acm/acm_redis.php +++ b/phpBB/includes/acm/acm_redis.php @@ -2,8 +2,7 @@ /** * * @package acm -* @version $Id$ -* @copyright (c) 2005, 2011 phpBB Group +* @copyright (c) 2011 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * */ @@ -40,6 +39,10 @@ if (!defined('PHPBB_ACM_REDIS')) /** * ACM for Redis +* +* Compatible with the php extension phpredis available +* at https://github.com/nicolasff/phpredis +* * @package acm */ class acm extends acm_memory From 9891f5a8d2025aeec19c6b33de0d1a48dd92d211 Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 29 Mar 2011 15:54:28 +0800 Subject: [PATCH 121/170] [ticket/10110] Enable the serialization and add a constant for defined the database PHPBB3-10110 --- phpBB/docs/coding-guidelines.html | 1 + phpBB/includes/acm/acm_redis.php | 32 ++++++++++++++++++++----------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/phpBB/docs/coding-guidelines.html b/phpBB/docs/coding-guidelines.html index 3f72ac406a..cd3c09f6fb 100644 --- a/phpBB/docs/coding-guidelines.html +++ b/phpBB/docs/coding-guidelines.html @@ -243,6 +243,7 @@ PHPBB_ACM_MEMCACHE_HOST (overwrite memcached host name, default is localhost PHPBB_ACM_REDIS_HOST (overwrite redis host name, default is localhost) PHPBB_ACM_REDIS_PORT (overwrite redis port, default is 6379) PHPBB_ACM_REDIS_PASSWORD (overwrite redis password, default is empty) +PHPBB_ACM_REDIS_DB (overwrite redis default database) PHPBB_QA (Set board to QA-Mode, which means the updater also checks for RC-releases) diff --git a/phpBB/includes/acm/acm_redis.php b/phpBB/includes/acm/acm_redis.php index b1739c0479..1c2b9c0c2f 100644 --- a/phpBB/includes/acm/acm_redis.php +++ b/phpBB/includes/acm/acm_redis.php @@ -48,7 +48,7 @@ if (!defined('PHPBB_ACM_REDIS')) class acm extends acm_memory { var $extension = 'redis'; - + var $redis; function acm() @@ -56,15 +56,10 @@ class acm extends acm_memory // Call the parent constructor parent::acm_memory(); - if (!extension_loaded('redis')) - { - trigger_error("Could not find required extension [{$this->extension}] for the ACM module $acm_type.", E_USER_ERROR); - } - $this->redis = new Redis(); - foreach (explode(',', PHPBB_ACM_REDIS) as $u) + foreach (explode(',', PHPBB_ACM_REDIS) as $server) { - $parts = explode('/', $u); + $parts = explode('/', $server); $this->redis->connect(trim($parts[0]), trim($parts[1])); } @@ -72,9 +67,24 @@ class acm extends acm_memory { if (!$this->redis->auth(PHPBB_ACM_REDIS_PASSWORD)) { + global $acm_type; + trigger_error("Incorrect password for the ACM module $acm_type.", E_USER_ERROR); } } + + $this->redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP); + $this->redis->setOption(Redis::OPT_PREFIX, $this->key_prefix); + + if (defined('PHPBB_ACM_REDIS_DB')) + { + if (!$this->redis->select(PHPBB_ACM_REDIS_DB)) + { + global $acm_type; + + trigger_error("Incorrect database for the ACM module $acm_type.", E_USER_ERROR); + } + } } /** @@ -110,7 +120,7 @@ class acm extends acm_memory */ function _read($var) { - return $this->redis->get($this->key_prefix . $var); + return $this->redis->get($var); } /** @@ -124,7 +134,7 @@ class acm extends acm_memory */ function _write($var, $data, $ttl = 2592000) { - return $this->redis->setex($this->key_prefix . $var, $ttl, $data); + return $this->redis->setex($var, $ttl, $data); } /** @@ -136,7 +146,7 @@ class acm extends acm_memory */ function _delete($var) { - if ($this->redis->delete($this->key_prefix . $var) > 0) + if ($this->redis->delete($var) > 0) { return true; } From ddda094d3abd2e5971c77cc38993eefa3d0bdf3a Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 30 Mar 2011 17:55:53 +0800 Subject: [PATCH 122/170] [ticket/10110] Remove tab from empty lines PHPBB3-10110 --- phpBB/includes/acm/acm_redis.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/acm/acm_redis.php b/phpBB/includes/acm/acm_redis.php index 1c2b9c0c2f..8954b9d0e7 100644 --- a/phpBB/includes/acm/acm_redis.php +++ b/phpBB/includes/acm/acm_redis.php @@ -48,7 +48,7 @@ if (!defined('PHPBB_ACM_REDIS')) class acm extends acm_memory { var $extension = 'redis'; - + var $redis; function acm() @@ -62,26 +62,26 @@ class acm extends acm_memory $parts = explode('/', $server); $this->redis->connect(trim($parts[0]), trim($parts[1])); } - + if (defined('PHPBB_ACM_REDIS_PASSWORD')) { if (!$this->redis->auth(PHPBB_ACM_REDIS_PASSWORD)) { global $acm_type; - + trigger_error("Incorrect password for the ACM module $acm_type.", E_USER_ERROR); } } - + $this->redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP); $this->redis->setOption(Redis::OPT_PREFIX, $this->key_prefix); - + if (defined('PHPBB_ACM_REDIS_DB')) { if (!$this->redis->select(PHPBB_ACM_REDIS_DB)) { global $acm_type; - + trigger_error("Incorrect database for the ACM module $acm_type.", E_USER_ERROR); } } From 87ed48f21bd4117629b8b6d4b1b9b535b0ef630e Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Thu, 31 Mar 2011 20:24:25 +0200 Subject: [PATCH 123/170] [ticket/10110] Remove redis acm driver from develop-olympus PHPBB3-10110 --- phpBB/includes/acm/acm_redis.php | 155 ------------------------------- 1 file changed, 155 deletions(-) delete mode 100644 phpBB/includes/acm/acm_redis.php diff --git a/phpBB/includes/acm/acm_redis.php b/phpBB/includes/acm/acm_redis.php deleted file mode 100644 index 8954b9d0e7..0000000000 --- a/phpBB/includes/acm/acm_redis.php +++ /dev/null @@ -1,155 +0,0 @@ -redis = new Redis(); - foreach (explode(',', PHPBB_ACM_REDIS) as $server) - { - $parts = explode('/', $server); - $this->redis->connect(trim($parts[0]), trim($parts[1])); - } - - if (defined('PHPBB_ACM_REDIS_PASSWORD')) - { - if (!$this->redis->auth(PHPBB_ACM_REDIS_PASSWORD)) - { - global $acm_type; - - trigger_error("Incorrect password for the ACM module $acm_type.", E_USER_ERROR); - } - } - - $this->redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP); - $this->redis->setOption(Redis::OPT_PREFIX, $this->key_prefix); - - if (defined('PHPBB_ACM_REDIS_DB')) - { - if (!$this->redis->select(PHPBB_ACM_REDIS_DB)) - { - global $acm_type; - - trigger_error("Incorrect database for the ACM module $acm_type.", E_USER_ERROR); - } - } - } - - /** - * Unload the cache resources - * - * @return void - */ - function unload() - { - parent::unload(); - - $this->redis->close(); - } - - /** - * Purge cache data - * - * @return void - */ - function purge() - { - $this->redis->flushDB(); - - parent::purge(); - } - - /** - * Fetch an item from the cache - * - * @access protected - * @param string $var Cache key - * @return mixed Cached data - */ - function _read($var) - { - return $this->redis->get($var); - } - - /** - * Store data in the cache - * - * @access protected - * @param string $var Cache key - * @param mixed $data Data to store - * @param int $ttl Time-to-live of cached data - * @return bool True if the operation succeeded - */ - function _write($var, $data, $ttl = 2592000) - { - return $this->redis->setex($var, $ttl, $data); - } - - /** - * Remove an item from the cache - * - * @access protected - * @param string $var Cache key - * @return bool True if the operation succeeded - */ - function _delete($var) - { - if ($this->redis->delete($var) > 0) - { - return true; - } - return false; - } -} From a83518982394f93e843e68f663fd39b2d6fd5150 Mon Sep 17 00:00:00 2001 From: rxu Date: Tue, 15 Mar 2011 22:21:43 +0700 Subject: [PATCH 124/170] [ticket/9751] Password requirement "Must contain letters and numbers" fails PHPBB3-9751 --- phpBB/includes/functions_user.php | 6 +- tests/regex/password_complexity_test.php | 81 ++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 tests/regex/password_complexity_test.php diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 8a204995aa..88e07f729c 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1617,7 +1617,6 @@ function validate_password($password) { $upp = '\p{Lu}'; $low = '\p{Ll}'; - $let = '\p{L}'; $num = '\p{N}'; $sym = '[^\p{Lu}\p{Ll}\p{N}]'; $pcre = true; @@ -1627,7 +1626,6 @@ function validate_password($password) mb_regex_encoding('UTF-8'); $upp = '[[:upper:]]'; $low = '[[:lower:]]'; - $let = '[[:lower:][:upper:]]'; $num = '[[:digit:]]'; $sym = '[^[:upper:][:lower:][:digit:]]'; $mbstring = true; @@ -1636,7 +1634,6 @@ function validate_password($password) { $upp = '[A-Z]'; $low = '[a-z]'; - $let = '[a-zA-Z]'; $num = '[0-9]'; $sym = '[^A-Za-z0-9]'; $pcre = true; @@ -1652,7 +1649,8 @@ function validate_password($password) break; case 'PASS_TYPE_ALPHA': - $chars[] = $let; + $chars[] = $low; + $chars[] = $upp; $chars[] = $num; break; diff --git a/tests/regex/password_complexity_test.php b/tests/regex/password_complexity_test.php new file mode 100644 index 0000000000..21e8d12a0a --- /dev/null +++ b/tests/regex/password_complexity_test.php @@ -0,0 +1,81 @@ +assertFalse(validate_password($password)); + } + + /** + * @dataProvider password_complexity_test_data_negative + */ + public function test_password_complexity_negative($password, $mode) + { + global $config; + $config['pass_complex'] = $mode; + $this->assertEquals('INVALID_CHARS', validate_password($password)); + } +} From dba8cf12fd2573edc9722076770140c7b4024f6b Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 25 Mar 2011 22:48:44 +0100 Subject: [PATCH 125/170] [ticket/9751] Use a switch/case block without break for password complexity. PHPBB3-9751 --- phpBB/includes/functions_user.php | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 88e07f729c..c51e571e31 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1643,23 +1643,25 @@ function validate_password($password) switch ($config['pass_complex']) { + // No break statements below ... + // We require strong passwords in case pass_complex is not set or is invalid + default: + + // Require mixed case letters, numbers and symbols + case 'PASS_TYPE_SYMBOL': + $chars[] = $sym; + + // Require mixed case letters and numbers + case 'PASS_TYPE_ALPHA': + $chars[] = $num; + + // Require mixed case letters case 'PASS_TYPE_CASE': $chars[] = $low; $chars[] = $upp; - break; - case 'PASS_TYPE_ALPHA': - $chars[] = $low; - $chars[] = $upp; - $chars[] = $num; - break; - - case 'PASS_TYPE_SYMBOL': - $chars[] = $low; - $chars[] = $upp; - $chars[] = $num; - $chars[] = $sym; - break; + // No requirements + case 'PASS_TYPE_ANY': } if ($pcre) From 7cc32d3843afbb754b3de101bda2267012647c2f Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 25 Mar 2011 23:11:15 +0100 Subject: [PATCH 126/170] [ticket/9751] Compare $password with empty string instead of casting it to bool PHPBB3-9751 --- phpBB/includes/functions_user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index c51e571e31..6ac6317dd2 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1605,7 +1605,7 @@ function validate_password($password) { global $config, $db, $user; - if (!$password) + if ($password === '') { return false; } From 4dce53628c97062b1085eb714892f6d81ae07699 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 25 Mar 2011 23:15:40 +0100 Subject: [PATCH 127/170] [ticket/9751] Add shortcut logic for pass_complex == PASS_TYPE_ANY. Add shortcut logic for pass_complex because this is the default value phpBB ships with and there is nothing to do in that function in that case. PHPBB3-9751 --- phpBB/includes/functions_user.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 6ac6317dd2..89ce52dc39 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1605,8 +1605,9 @@ function validate_password($password) { global $config, $db, $user; - if ($password === '') + if ($password === '' || $config['pass_complex'] === 'PASS_TYPE_ANY') { + // Password empty or no password complexity required. return false; } @@ -1659,9 +1660,6 @@ function validate_password($password) case 'PASS_TYPE_CASE': $chars[] = $low; $chars[] = $upp; - - // No requirements - case 'PASS_TYPE_ANY': } if ($pcre) From 646d3e10d2fad2521d7239ed2a2a8fe90e6e7234 Mon Sep 17 00:00:00 2001 From: rxu Date: Sat, 2 Apr 2011 19:07:13 +0800 Subject: [PATCH 128/170] [ticket/10115] Make some text oriented BBCodes to properly handle unicode. [quote], [b], [i], [size], [color], [u], [list] are affected. PHPBB3-10115 --- phpBB/includes/message_parser.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index b2d0b6c566..cc687b6fec 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -111,16 +111,16 @@ class bbcode_firstpass extends bbcode // [quote] in second position. $this->bbcodes = array( 'code' => array('bbcode_id' => 8, 'regexp' => array('#\[code(?:=([a-z]+))?\](.+\[/code\])#ise' => "\$this->bbcode_code('\$1', '\$2')")), - 'quote' => array('bbcode_id' => 0, 'regexp' => array('#\[quote(?:="(.*?)")?\](.+)\[/quote\]#ise' => "\$this->bbcode_quote('\$0')")), + 'quote' => array('bbcode_id' => 0, 'regexp' => array('#\[quote(?:="(.*?)")?\](.+)\[/quote\]#uise' => "\$this->bbcode_quote('\$0')")), 'attachment' => array('bbcode_id' => 12, 'regexp' => array('#\[attachment=([0-9]+)\](.*?)\[/attachment\]#ise' => "\$this->bbcode_attachment('\$1', '\$2')")), - 'b' => array('bbcode_id' => 1, 'regexp' => array('#\[b\](.*?)\[/b\]#ise' => "\$this->bbcode_strong('\$1')")), - 'i' => array('bbcode_id' => 2, 'regexp' => array('#\[i\](.*?)\[/i\]#ise' => "\$this->bbcode_italic('\$1')")), + 'b' => array('bbcode_id' => 1, 'regexp' => array('#\[b\](.*?)\[/b\]#uise' => "\$this->bbcode_strong('\$1')")), + 'i' => array('bbcode_id' => 2, 'regexp' => array('#\[i\](.*?)\[/i\]#uise' => "\$this->bbcode_italic('\$1')")), 'url' => array('bbcode_id' => 3, 'regexp' => array('#\[url(=(.*))?\](.*)\[/url\]#iUe' => "\$this->validate_url('\$2', '\$3')")), 'img' => array('bbcode_id' => 4, 'regexp' => array('#\[img\](.*)\[/img\]#iUe' => "\$this->bbcode_img('\$1')")), - 'size' => array('bbcode_id' => 5, 'regexp' => array('#\[size=([\-\+]?\d+)\](.*?)\[/size\]#ise' => "\$this->bbcode_size('\$1', '\$2')")), - 'color' => array('bbcode_id' => 6, 'regexp' => array('!\[color=(#[0-9a-f]{3}|#[0-9a-f]{6}|[a-z\-]+)\](.*?)\[/color\]!ise' => "\$this->bbcode_color('\$1', '\$2')")), - 'u' => array('bbcode_id' => 7, 'regexp' => array('#\[u\](.*?)\[/u\]#ise' => "\$this->bbcode_underline('\$1')")), - 'list' => array('bbcode_id' => 9, 'regexp' => array('#\[list(?:=(?:[a-z0-9]|disc|circle|square))?].*\[/list]#ise' => "\$this->bbcode_parse_list('\$0')")), + 'size' => array('bbcode_id' => 5, 'regexp' => array('#\[size=([\-\+]?\d+)\](.*?)\[/size\]#uise' => "\$this->bbcode_size('\$1', '\$2')")), + 'color' => array('bbcode_id' => 6, 'regexp' => array('!\[color=(#[0-9a-f]{3}|#[0-9a-f]{6}|[a-z\-]+)\](.*?)\[/color\]!uise' => "\$this->bbcode_color('\$1', '\$2')")), + 'u' => array('bbcode_id' => 7, 'regexp' => array('#\[u\](.*?)\[/u\]#uise' => "\$this->bbcode_underline('\$1')")), + 'list' => array('bbcode_id' => 9, 'regexp' => array('#\[list(?:=(?:[a-z0-9]|disc|circle|square))?].*\[/list]#uise' => "\$this->bbcode_parse_list('\$0')")), 'email' => array('bbcode_id' => 10, 'regexp' => array('#\[email=?(.*?)?\](.*?)\[/email\]#ise' => "\$this->validate_email('\$1', '\$2')")), 'flash' => array('bbcode_id' => 11, 'regexp' => array('#\[flash=([0-9]+),([0-9]+)\](.*?)\[/flash\]#ie' => "\$this->bbcode_flash('\$1', '\$2', '\$3')")) ); From 25ae46b8df36f040f7f3adc1e4aebb4041d79964 Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 3 Apr 2011 00:53:00 +0800 Subject: [PATCH 129/170] [ticket/10117] Make smilies to be correctly parsed within unicode text. PHPBB3-10117 --- phpBB/includes/message_parser.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index b2d0b6c566..7c12321d51 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -1332,7 +1332,7 @@ class parse_message extends bbcode_firstpass { if ($max_smilies) { - $num_matches = preg_match_all('#(?<=^|[\n .])(?:' . implode('|', $match) . ')(?![^<>]*>)#', $this->message, $matches); + $num_matches = preg_match_all('#(?<=^|[\n .])(?:' . implode('|', $match) . ')(?![^<>]*>)#u', $this->message, $matches); unset($matches); if ($num_matches !== false && $num_matches > $max_smilies) @@ -1343,7 +1343,7 @@ class parse_message extends bbcode_firstpass } // Make sure the delimiter # is added in front and at the end of every element within $match - $this->message = trim(preg_replace(explode(chr(0), '#(?<=^|[\n .])' . implode('(?![^<>]*>)#' . chr(0) . '#(?<=^|[\n .])', $match) . '(?![^<>]*>)#'), $replace, $this->message)); + $this->message = trim(preg_replace(explode(chr(0), '#(?<=^|[\n .])' . implode('(?![^<>]*>)#u' . chr(0) . '#(?<=^|[\n .])', $match) . '(?![^<>]*>)#'), $replace, $this->message)); } } From 6ddb92c41e63e21612efaa0d420f19374786dfc0 Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 3 Apr 2011 08:33:33 +0800 Subject: [PATCH 130/170] [ticket/10115] Switch UTF-8 mode on for the rest of BBCodes PHPBB3-10115 --- phpBB/includes/message_parser.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index cc687b6fec..26532e84c0 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -110,19 +110,19 @@ class bbcode_firstpass extends bbcode // order, so it is important to keep [code] in first position and // [quote] in second position. $this->bbcodes = array( - 'code' => array('bbcode_id' => 8, 'regexp' => array('#\[code(?:=([a-z]+))?\](.+\[/code\])#ise' => "\$this->bbcode_code('\$1', '\$2')")), + 'code' => array('bbcode_id' => 8, 'regexp' => array('#\[code(?:=([a-z]+))?\](.+\[/code\])#uise' => "\$this->bbcode_code('\$1', '\$2')")), 'quote' => array('bbcode_id' => 0, 'regexp' => array('#\[quote(?:="(.*?)")?\](.+)\[/quote\]#uise' => "\$this->bbcode_quote('\$0')")), - 'attachment' => array('bbcode_id' => 12, 'regexp' => array('#\[attachment=([0-9]+)\](.*?)\[/attachment\]#ise' => "\$this->bbcode_attachment('\$1', '\$2')")), + 'attachment' => array('bbcode_id' => 12, 'regexp' => array('#\[attachment=([0-9]+)\](.*?)\[/attachment\]#uise' => "\$this->bbcode_attachment('\$1', '\$2')")), 'b' => array('bbcode_id' => 1, 'regexp' => array('#\[b\](.*?)\[/b\]#uise' => "\$this->bbcode_strong('\$1')")), 'i' => array('bbcode_id' => 2, 'regexp' => array('#\[i\](.*?)\[/i\]#uise' => "\$this->bbcode_italic('\$1')")), - 'url' => array('bbcode_id' => 3, 'regexp' => array('#\[url(=(.*))?\](.*)\[/url\]#iUe' => "\$this->validate_url('\$2', '\$3')")), - 'img' => array('bbcode_id' => 4, 'regexp' => array('#\[img\](.*)\[/img\]#iUe' => "\$this->bbcode_img('\$1')")), + 'url' => array('bbcode_id' => 3, 'regexp' => array('#\[url(=(.*))?\](.*)\[/url\]#uiUe' => "\$this->validate_url('\$2', '\$3')")), + 'img' => array('bbcode_id' => 4, 'regexp' => array('#\[img\](.*)\[/img\]#uiUe' => "\$this->bbcode_img('\$1')")), 'size' => array('bbcode_id' => 5, 'regexp' => array('#\[size=([\-\+]?\d+)\](.*?)\[/size\]#uise' => "\$this->bbcode_size('\$1', '\$2')")), 'color' => array('bbcode_id' => 6, 'regexp' => array('!\[color=(#[0-9a-f]{3}|#[0-9a-f]{6}|[a-z\-]+)\](.*?)\[/color\]!uise' => "\$this->bbcode_color('\$1', '\$2')")), 'u' => array('bbcode_id' => 7, 'regexp' => array('#\[u\](.*?)\[/u\]#uise' => "\$this->bbcode_underline('\$1')")), 'list' => array('bbcode_id' => 9, 'regexp' => array('#\[list(?:=(?:[a-z0-9]|disc|circle|square))?].*\[/list]#uise' => "\$this->bbcode_parse_list('\$0')")), - 'email' => array('bbcode_id' => 10, 'regexp' => array('#\[email=?(.*?)?\](.*?)\[/email\]#ise' => "\$this->validate_email('\$1', '\$2')")), - 'flash' => array('bbcode_id' => 11, 'regexp' => array('#\[flash=([0-9]+),([0-9]+)\](.*?)\[/flash\]#ie' => "\$this->bbcode_flash('\$1', '\$2', '\$3')")) + 'email' => array('bbcode_id' => 10, 'regexp' => array('#\[email=?(.*?)?\](.*?)\[/email\]#uise' => "\$this->validate_email('\$1', '\$2')")), + 'flash' => array('bbcode_id' => 11, 'regexp' => array('#\[flash=([0-9]+),([0-9]+)\](.*?)\[/flash\]#uie' => "\$this->bbcode_flash('\$1', '\$2', '\$3')")) ); // Zero the parsed items array From b8adad0d48845540083519651bf9befb6cffaceb Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 3 Apr 2011 15:28:00 +0800 Subject: [PATCH 131/170] [ticket/10117] Add one more missed 'u' modifier, add code comment PHPBB3-10117 --- phpBB/includes/message_parser.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 7c12321d51..5a7dd9d11e 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -1332,6 +1332,8 @@ class parse_message extends bbcode_firstpass { if ($max_smilies) { + // 'u' modifier has been added to correctly parse smilies within unicode strings + // For details: http://tracker.phpbb.com/browse/PHPBB3-10117 $num_matches = preg_match_all('#(?<=^|[\n .])(?:' . implode('|', $match) . ')(?![^<>]*>)#u', $this->message, $matches); unset($matches); @@ -1343,7 +1345,10 @@ class parse_message extends bbcode_firstpass } // Make sure the delimiter # is added in front and at the end of every element within $match - $this->message = trim(preg_replace(explode(chr(0), '#(?<=^|[\n .])' . implode('(?![^<>]*>)#u' . chr(0) . '#(?<=^|[\n .])', $match) . '(?![^<>]*>)#'), $replace, $this->message)); + // 'u' modifier has been added to correctly parse smilies within unicode strings + // For details: http://tracker.phpbb.com/browse/PHPBB3-10117 + + $this->message = trim(preg_replace(explode(chr(0), '#(?<=^|[\n .])' . implode('(?![^<>]*>)#u' . chr(0) . '#(?<=^|[\n .])', $match) . '(?![^<>]*>)#u'), $replace, $this->message)); } } From 59d75c1ae6df1546da998a3748a82f14cde604b1 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 3 Apr 2011 21:12:01 +0200 Subject: [PATCH 132/170] [ticket/10121] Fix ICQ profile link, leading to a dead web-messenger. PHPBB3-10121 --- phpBB/includes/ucp/ucp_pm_viewmessage.php | 2 +- phpBB/memberlist.php | 2 +- phpBB/viewtopic.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index b91636a9c8..d0cfa1ffd2 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -208,7 +208,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) 'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($user_info['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $author_id) : '', 'U_WWW' => (!empty($user_info['user_website'])) ? $user_info['user_website'] : '', - 'U_ICQ' => ($user_info['user_icq']) ? 'http://www.icq.com/people/webmsg.php?to=' . urlencode($user_info['user_icq']) : '', + 'U_ICQ' => ($user_info['user_icq']) ? 'http://www.icq.com/people' . urlencode($user_info['user_icq']) . '/' : '', 'U_AIM' => ($user_info['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=aim&u=' . $author_id) : '', 'U_YIM' => ($user_info['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($user_info['user_yim']) . '&.src=pg' : '', 'U_MSN' => ($user_info['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=msnm&u=' . $author_id) : '', diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 599cd0b3e7..589877305f 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1716,7 +1716,7 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f 'U_EMAIL' => $email, 'U_WWW' => (!empty($data['user_website'])) ? $data['user_website'] : '', 'U_SHORT_WWW' => (!empty($data['user_website'])) ? ((strlen($data['user_website']) > 55) ? substr($data['user_website'], 0, 39) . ' ... ' . substr($data['user_website'], -10) : $data['user_website']) : '', - 'U_ICQ' => ($data['user_icq']) ? 'http://www.icq.com/people/webmsg.php?to=' . urlencode($data['user_icq']) : '', + 'U_ICQ' => ($data['user_icq']) ? 'http://www.icq.com/people/' . urlencode($data['user_icq']) . '/' : '', 'U_AIM' => ($data['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=aim&u=' . $user_id) : '', 'U_YIM' => ($data['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($data['user_yim']) . '&.src=pg' : '', 'U_MSN' => ($data['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=msnm&u=' . $user_id) : '', diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index bc839066a5..80ba4d8a54 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1157,7 +1157,7 @@ while ($row = $db->sql_fetchrow($result)) if (!empty($row['user_icq'])) { - $user_cache[$poster_id]['icq'] = 'http://www.icq.com/people/webmsg.php?to=' . $row['user_icq']; + $user_cache[$poster_id]['icq'] = 'http://www.icq.com/people/' . $row['user_icq'] . '/'; $user_cache[$poster_id]['icq_status_img'] = ''; } else From f96cb431a9b47e06f4104dfc3d6ebd613ef0d733 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 3 Apr 2011 22:14:26 +0200 Subject: [PATCH 133/170] [ticket/10121] Fix missing urlencode() for ICQ-number in viewtopic.php PHPBB3-10121 --- phpBB/viewtopic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 80ba4d8a54..53da7f539f 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1157,7 +1157,7 @@ while ($row = $db->sql_fetchrow($result)) if (!empty($row['user_icq'])) { - $user_cache[$poster_id]['icq'] = 'http://www.icq.com/people/' . $row['user_icq'] . '/'; + $user_cache[$poster_id]['icq'] = 'http://www.icq.com/people/' . urlencode($row['user_icq']) . '/'; $user_cache[$poster_id]['icq_status_img'] = ''; } else From 3352141264993982215b714ac7a128854494ac1f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Mar 2010 00:38:56 +0100 Subject: [PATCH 134/170] [ticket/9684] Remove code for global announcement in root-files PHPBB3-9684 --- phpBB/feed.php | 120 +++--------- phpBB/includes/mcp/mcp_main.php | 171 ++---------------- phpBB/mcp.php | 14 +- phpBB/memberlist.php | 2 +- phpBB/posting.php | 60 +----- phpBB/report.php | 2 +- phpBB/search.php | 31 +--- .../prosilver/template/search_results.html | 11 +- phpBB/viewforum.php | 4 +- phpBB/viewtopic.php | 72 +------- 10 files changed, 55 insertions(+), 432 deletions(-) diff --git a/phpBB/feed.php b/phpBB/feed.php index 7af422629d..1a09e4da23 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -775,9 +775,6 @@ class phpbb_feed_overall extends phpbb_feed_post_base return false; } - // Add global forum id - $forum_ids[] = 0; - // m_approve forums $fid_m_approve = $this->get_moderator_approve_forums(); $sql_m_approve = (!empty($fid_m_approve)) ? 'OR ' . $db->sql_in_set('forum_id', $fid_m_approve) : ''; @@ -915,12 +912,11 @@ class phpbb_feed_forum extends phpbb_feed_post_base global $auth, $db; $m_approve = ($auth->acl_get('m_approve', $this->forum_id)) ? true : false; - $forum_ids = array(0, $this->forum_id); // Determine topics with recent activity $sql = 'SELECT topic_id, topic_last_post_time FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids) . ' + WHERE forum_id = ' . $this->forum_id . ' AND topic_moved_id = 0 ' . ((!$m_approve) ? 'AND topic_approved = 1' : '') . ' ORDER BY topic_last_post_time DESC'; @@ -1009,96 +1005,37 @@ class phpbb_feed_topic extends phpbb_feed_post_base trigger_error('NO_TOPIC'); } - if ($this->topic_data['topic_type'] == POST_GLOBAL) + $this->forum_id = (int) $this->topic_data['forum_id']; + + // Make sure topic is either approved or user authed + if (!$this->topic_data['topic_approved'] && !$auth->acl_get('m_approve', $this->forum_id)) { - // We need to find at least one postable forum where feeds are enabled, - // that the user can read and maybe also has approve permissions. - $in_fid_ary = $this->get_readable_forums(); - - if (empty($in_fid_ary)) - { - // User cannot read any forums - trigger_error('SORRY_AUTH_READ'); - } - - if (!$this->topic_data['topic_approved']) - { - // Also require m_approve - $in_fid_ary = array_intersect($in_fid_ary, $this->get_moderator_approve_forums()); - - if (empty($in_fid_ary)) - { - trigger_error('SORRY_AUTH_READ'); - } - } - - // Diff excluded forums - $in_fid_ary = array_diff($in_fid_ary, $this->get_excluded_forums()); - - if (empty($in_fid_ary)) - { - trigger_error('SORRY_AUTH_READ'); - } - - // Also exclude passworded forums - $in_fid_ary = array_diff($in_fid_ary, $this->get_passworded_forums()); - - if (empty($in_fid_ary)) - { - trigger_error('SORRY_AUTH_READ'); - } - - $sql = 'SELECT forum_id, left_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_type = ' . FORUM_POST . ' - AND ' . $db->sql_in_set('forum_id', $in_fid_ary) . ' - ORDER BY left_id ASC'; - $result = $db->sql_query_limit($sql, 1); - $this->forum_data = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (empty($this->forum_data)) - { - // No forum found. - trigger_error('SORRY_AUTH_READ'); - } - - unset($in_fid_ary); + trigger_error('SORRY_AUTH_READ'); } - else + + // Make sure forum is not excluded from feed + if (phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $this->topic_data['forum_options'])) { - $this->forum_id = (int) $this->topic_data['forum_id']; + trigger_error('NO_FEED'); + } - // Make sure topic is either approved or user authed - if (!$this->topic_data['topic_approved'] && !$auth->acl_get('m_approve', $this->forum_id)) + // Make sure we can read this forum + if (!$auth->acl_get('f_read', $this->forum_id)) + { + trigger_error('SORRY_AUTH_READ'); + } + + // Make sure forum is not passworded or user is authed + if ($this->topic_data['forum_password']) + { + $forum_ids_passworded = $this->get_passworded_forums(); + + if (isset($forum_ids_passworded[$this->forum_id])) { trigger_error('SORRY_AUTH_READ'); } - // Make sure forum is not excluded from feed - if (phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $this->topic_data['forum_options'])) - { - trigger_error('NO_FEED'); - } - - // Make sure we can read this forum - if (!$auth->acl_get('f_read', $this->forum_id)) - { - trigger_error('SORRY_AUTH_READ'); - } - - // Make sure forum is not passworded or user is authed - if ($this->topic_data['forum_password']) - { - $forum_ids_passworded = $this->get_passworded_forums(); - - if (isset($forum_ids_passworded[$this->forum_id])) - { - trigger_error('SORRY_AUTH_READ'); - } - - unset($forum_ids_passworded); - } + unset($forum_ids_passworded); } } @@ -1245,9 +1182,6 @@ class phpbb_feed_news extends phpbb_feed_topic_base return false; } - // Add global forum - $in_fid_ary[] = 0; - // We really have to get the post ids first! $sql = 'SELECT topic_first_post_id, topic_time FROM ' . TOPICS_TABLE . ' @@ -1318,9 +1252,6 @@ class phpbb_feed_topics extends phpbb_feed_topic_base return false; } - // Add global forum - $in_fid_ary[] = 0; - // We really have to get the post ids first! $sql = 'SELECT topic_first_post_id, topic_time FROM ' . TOPICS_TABLE . ' @@ -1410,9 +1341,6 @@ class phpbb_feed_topics_active extends phpbb_feed_topic_base return false; } - // Add global forum - $in_fid_ary[] = 0; - // Search for topics in last X days $last_post_time_sql = ($this->sort_days) ? ' AND topic_last_post_time > ' . (time() - ($this->sort_days * 24 * 3600)) : ''; diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index db7bc7c7ea..b9964f48a7 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -333,131 +333,22 @@ function change_topic_type($action, $topic_ids) if (confirm_box(true)) { - if ($new_topic_type != POST_GLOBAL) + $sql = 'UPDATE ' . TOPICS_TABLE . " + SET topic_type = $new_topic_type + WHERE " . $db->sql_in_set('topic_id', $topic_ids); + $db->sql_query($sql); + + if (($new_topic_type == POST_GLOBAL) && sizeof($topic_ids)) { - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_type = $new_topic_type - WHERE " . $db->sql_in_set('topic_id', $topic_ids) . ' - AND forum_id <> 0'; + // Delete topic shadows for global announcements + $sql = 'DELETE FROM ' . TOPICS_TABLE . ' + WHERE ' . $db->sql_in_set('topic_moved_id', $topic_ids); $db->sql_query($sql); - // Reset forum id if a global topic is within the array - $to_forum_id = request_var('to_forum_id', 0); - - if ($to_forum_id) - { - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_type = $new_topic_type, forum_id = $to_forum_id - WHERE " . $db->sql_in_set('topic_id', $topic_ids) . ' - AND forum_id = 0'; - $db->sql_query($sql); - - // Update forum_ids for all posts - $sql = 'UPDATE ' . POSTS_TABLE . " - SET forum_id = $to_forum_id - WHERE " . $db->sql_in_set('topic_id', $topic_ids) . ' - AND forum_id = 0'; - $db->sql_query($sql); - - // Do a little forum sync stuff - $sql = 'SELECT SUM(t.topic_replies + t.topic_approved) as topic_posts, COUNT(t.topic_approved) as topics_authed - FROM ' . TOPICS_TABLE . ' t - WHERE ' . $db->sql_in_set('t.topic_id', $topic_ids); - $result = $db->sql_query($sql); - $row_data = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $sync_sql = array(); - - if ($row_data['topic_posts']) - { - $sync_sql[$to_forum_id][] = 'forum_posts = forum_posts + ' . (int) $row_data['topic_posts']; - } - - if ($row_data['topics_authed']) - { - $sync_sql[$to_forum_id][] = 'forum_topics = forum_topics + ' . (int) $row_data['topics_authed']; - } - - $sync_sql[$to_forum_id][] = 'forum_topics_real = forum_topics_real + ' . (int) sizeof($topic_ids); - - foreach ($sync_sql as $forum_id_key => $array) - { - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET ' . implode(', ', $array) . ' - WHERE forum_id = ' . $forum_id_key; - $db->sql_query($sql); - } - - sync('forum', 'forum_id', $to_forum_id); - } - } - else - { - // Get away with those topics already being a global announcement by re-calculating $topic_ids - $sql = 'SELECT topic_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . ' - AND forum_id <> 0'; - $result = $db->sql_query($sql); - - $topic_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $topic_ids[] = $row['topic_id']; - } - $db->sql_freeresult($result); - - if (sizeof($topic_ids)) - { - // Delete topic shadows for global announcements - $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_moved_id', $topic_ids); - $db->sql_query($sql); - - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_type = $new_topic_type, forum_id = 0 - WHERE " . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - - // Update forum_ids for all posts - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET forum_id = 0 - WHERE ' . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - - // Do a little forum sync stuff - $sql = 'SELECT SUM(t.topic_replies + t.topic_approved) as topic_posts, COUNT(t.topic_approved) as topics_authed - FROM ' . TOPICS_TABLE . ' t - WHERE ' . $db->sql_in_set('t.topic_id', $topic_ids); - $result = $db->sql_query($sql); - $row_data = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $sync_sql = array(); - - if ($row_data['topic_posts']) - { - $sync_sql[$forum_id][] = 'forum_posts = forum_posts - ' . (int) $row_data['topic_posts']; - } - - if ($row_data['topics_authed']) - { - $sync_sql[$forum_id][] = 'forum_topics = forum_topics - ' . (int) $row_data['topics_authed']; - } - - $sync_sql[$forum_id][] = 'forum_topics_real = forum_topics_real - ' . (int) sizeof($topic_ids); - - foreach ($sync_sql as $forum_id_key => $array) - { - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET ' . implode(', ', $array) . ' - WHERE forum_id = ' . $forum_id_key; - $db->sql_query($sql); - } - - sync('forum', 'forum_id', $forum_id); - } + $sql = 'UPDATE ' . TOPICS_TABLE . " + SET topic_type = $new_topic_type + WHERE " . $db->sql_in_set('topic_id', $topic_ids); + $db->sql_query($sql); } $success_msg = (sizeof($topic_ids) == 1) ? 'TOPIC_TYPE_CHANGED' : 'TOPICS_TYPE_CHANGED'; @@ -474,41 +365,7 @@ function change_topic_type($action, $topic_ids) } else { - // Global topic involved? - $global_involved = false; - - if ($new_topic_type != POST_GLOBAL) - { - $sql = 'SELECT forum_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . ' - AND forum_id = 0'; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $global_involved = true; - } - } - - if ($global_involved) - { - global $template; - - $template->assign_vars(array( - 'S_FORUM_SELECT' => make_forum_select(request_var('f', $forum_id), false, false, true, true), - 'S_CAN_LEAVE_SHADOW' => false, - 'ADDITIONAL_MSG' => (sizeof($topic_ids) == 1) ? $user->lang['SELECT_FORUM_GLOBAL_ANNOUNCEMENT'] : $user->lang['SELECT_FORUM_GLOBAL_ANNOUNCEMENTS']) - ); - - confirm_box(false, $l_new_type, build_hidden_fields($s_hidden_fields), 'mcp_move.html'); - } - else - { - confirm_box(false, $l_new_type, build_hidden_fields($s_hidden_fields)); - } + confirm_box(false, $l_new_type, build_hidden_fields($s_hidden_fields)); } $redirect = request_var('redirect', "index.$phpEx"); diff --git a/phpBB/mcp.php b/phpBB/mcp.php index 401a12d0f9..0029d224cd 100644 --- a/phpBB/mcp.php +++ b/phpBB/mcp.php @@ -85,7 +85,7 @@ if ($post_id) $db->sql_freeresult($result); $topic_id = (int) $row['topic_id']; - $forum_id = (int) ($row['forum_id']) ? $row['forum_id'] : $forum_id; + $forum_id = (int) $row['forum_id']; } else if ($topic_id) { @@ -400,12 +400,6 @@ function get_topic_data($topic_ids, $acl_list = false, $read_tracking = false) while ($row = $db->sql_fetchrow($result)) { - if (!$row['forum_id']) - { - // Global Announcement? - $row['forum_id'] = request_var('f', 0); - } - $rowset[$row['topic_id']] = $row; if ($acl_list && !$auth->acl_gets($acl_list, $row['forum_id'])) @@ -485,12 +479,6 @@ function get_post_data($post_ids, $acl_list = false, $read_tracking = false) while ($row = $db->sql_fetchrow($result)) { - if (!$row['forum_id']) - { - // Global Announcement? - $row['forum_id'] = request_var('f', 0); - } - if ($acl_list && !$auth->acl_gets($acl_list, $row['forum_id'])) { continue; diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index ff74d0d0cd..64d29d18bd 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1136,7 +1136,7 @@ switch ($mode) $sql = 'SELECT DISTINCT poster_id FROM ' . POSTS_TABLE . ' WHERE poster_ip ' . ((strpos($ips, '%') !== false) ? 'LIKE' : 'IN') . " ($ips) - AND forum_id IN (0, " . implode(', ', $ip_forums) . ')'; + AND forum_id IN (" . implode(', ', $ip_forums) . ')'; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) diff --git a/phpBB/posting.php b/phpBB/posting.php index 41559056b9..2fcfd126eb 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -87,8 +87,7 @@ switch ($mode) $sql = 'SELECT f.*, t.* FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f WHERE t.topic_id = $topic_id - AND (f.forum_id = t.forum_id - OR f.forum_id = $forum_id)" . + AND f.forum_id = t.forum_id" . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1'); break; @@ -116,8 +115,7 @@ switch ($mode) WHERE p.post_id = $post_id AND t.topic_id = p.topic_id AND u.user_id = p.poster_id - AND (f.forum_id = t.forum_id - OR f.forum_id = $forum_id)" . + AND f.forum_id = t.forum_id" . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND p.post_approved = 1'); break; @@ -1005,60 +1003,6 @@ if ($submit || $preview || $refresh) // Store message, sync counters if (!sizeof($error) && $submit) { - // Check if we want to de-globalize the topic... and ask for new forum - if ($post_data['topic_type'] != POST_GLOBAL) - { - $sql = 'SELECT topic_type, forum_id - FROM ' . TOPICS_TABLE . " - WHERE topic_id = $topic_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row && !$row['forum_id'] && $row['topic_type'] == POST_GLOBAL) - { - $to_forum_id = request_var('to_forum_id', 0); - - if ($to_forum_id) - { - $sql = 'SELECT forum_type - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $to_forum_id; - $result = $db->sql_query($sql); - $forum_type = (int) $db->sql_fetchfield('forum_type'); - $db->sql_freeresult($result); - - if ($forum_type != FORUM_POST || !$auth->acl_get('f_post', $to_forum_id) || (!$auth->acl_get('m_approve', $to_forum_id) && !$auth->acl_get('f_noapprove', $to_forum_id))) - { - $to_forum_id = 0; - } - } - - if (!$to_forum_id) - { - include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); - - $template->assign_vars(array( - 'S_FORUM_SELECT' => make_forum_select(false, false, false, true, true, true), - 'S_UNGLOBALISE' => true) - ); - - $submit = false; - $refresh = true; - } - else - { - if (!$auth->acl_get('f_post', $to_forum_id)) - { - // This will only be triggered if the user tried to trick the forum. - trigger_error('NOT_AUTHORISED'); - } - - $forum_id = $to_forum_id; - } - } - } - if ($submit) { // Lock/Unlock Topic diff --git a/phpBB/report.php b/phpBB/report.php index 8e780813ff..a30914392b 100644 --- a/phpBB/report.php +++ b/phpBB/report.php @@ -70,7 +70,7 @@ if ($post_id) trigger_error('POST_NOT_EXIST'); } - $forum_id = (int) ($report_data['forum_id']) ? $report_data['forum_id'] : $forum_id; + $forum_id = (int) $report_data['forum_id']; $topic_id = (int) $report_data['topic_id']; $sql = 'SELECT * diff --git a/phpBB/search.php b/phpBB/search.php index 7f5c49f4fc..c68931f33f 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -832,35 +832,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) $result_topic_id = $row['topic_id']; $topic_title = censor_text($row['topic_title']); - // we need to select a forum id for this global topic - if (!$forum_id) - { - if (!isset($g_forum_id)) - { - // Get a list of forums the user cannot read - $forum_ary = array_unique(array_keys($auth->acl_getf('!f_read', true))); - - // Determine first forum the user is able to read (must not be a category) - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_type = ' . FORUM_POST; - - if (sizeof($forum_ary)) - { - $sql .= ' AND ' . $db->sql_in_set('forum_id', $forum_ary, true); - } - - $result = $db->sql_query_limit($sql, 1); - $g_forum_id = (int) $db->sql_fetchfield('forum_id'); - } - $u_forum_id = $g_forum_id; - } - else - { - $u_forum_id = $forum_id; - } - - $view_topic_url_params = "f=$u_forum_id&t=$result_topic_id" . (($u_hilit) ? "&hilit=$u_hilit" : ''); + $view_topic_url_params = "f=$forum_id&t=$result_topic_id" . (($u_hilit) ? "&hilit=$u_hilit" : ''); $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params); $replies = ($auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies']; @@ -911,7 +883,6 @@ if ($keywords || $author || $author_id || $search_id || $submit) 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', 'UNAPPROVED_IMG' => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', - 'S_TOPIC_GLOBAL' => (!$forum_id) ? true : false, 'S_TOPIC_TYPE' => $row['topic_type'], 'S_USER_POSTED' => (!empty($row['topic_posted'])) ? true : false, 'S_UNREAD_TOPIC' => $unread_topic, diff --git a/phpBB/styles/prosilver/template/search_results.html b/phpBB/styles/prosilver/template/search_results.html index fec71c1051..942d154d44 100644 --- a/phpBB/styles/prosilver/template/search_results.html +++ b/phpBB/styles/prosilver/template/search_results.html @@ -58,8 +58,7 @@ {searchresults.UNAPPROVED_IMG} {REPORTED_IMG}
{searchresults.PAGINATION} - {L_POST_BY_AUTHOR} {searchresults.TOPIC_AUTHOR_FULL} » {searchresults.FIRST_POST_TIME} - {L_IN} {searchresults.FORUM_TITLE} ({L_GLOBAL}) + {L_POST_BY_AUTHOR} {searchresults.TOPIC_AUTHOR_FULL} » {searchresults.FIRST_POST_TIME} » {L_IN} {searchresults.FORUM_TITLE}
{searchresults.TOPIC_REPLIES}
{searchresults.TOPIC_VIEWS}
@@ -102,12 +101,8 @@
{L_POST_BY_AUTHOR} {searchresults.POST_AUTHOR_FULL}
{searchresults.POST_DATE}
 
- -
{L_FORUM}: {searchresults.FORUM_TITLE}
-
{L_TOPIC}: {searchresults.TOPIC_TITLE}
- -
{L_GLOBAL}: {searchresults.TOPIC_TITLE}
- +
{L_FORUM}: {searchresults.FORUM_TITLE}
+
{L_TOPIC}: {searchresults.TOPIC_TITLE}
{L_REPLIES}: {searchresults.TOPIC_REPLIES}
{L_VIEWS}: {searchresults.TOPIC_VIEWS}
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 16d8b56d88..ebf2dc3501 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -365,8 +365,8 @@ if ($forum_data['forum_type'] == FORUM_POST) 'FROM' => $sql_array['FROM'], 'LEFT_JOIN' => $sql_array['LEFT_JOIN'], - 'WHERE' => 't.forum_id IN (' . $forum_id . ', 0) - AND t.topic_type IN (' . POST_ANNOUNCE . ', ' . POST_GLOBAL . ')', + 'WHERE' => '(t.forum_id = ' . $forum_id . ' + AND t.topic_type = ' . POST_ANNOUNCE . ') OR t.topic_type = ' . POST_GLOBAL, 'ORDER_BY' => 't.topic_time DESC', )); diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 6c188eeee3..53119e2ae7 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -152,26 +152,12 @@ if ($view && !$post_id) else { $topic_id = $row['topic_id']; - - // Check for global announcement correctness? - if (!$row['forum_id'] && !$forum_id) - { - trigger_error('NO_TOPIC'); - } - else if ($row['forum_id']) - { - $forum_id = $row['forum_id']; - } + $forum_id = $row['forum_id']; } } } - // Check for global announcement correctness? - if ((!isset($row) || !$row['forum_id']) && !$forum_id) - { - trigger_error('NO_TOPIC'); - } - else if (isset($row) && $row['forum_id']) + if (isset($row) && $row['forum_id']) { $forum_id = $row['forum_id']; } @@ -186,13 +172,6 @@ $sql_array = array( 'FROM' => array(FORUMS_TABLE => 'f'), ); -// Firebird handles two columns of the same name a little differently, this -// addresses that by forcing the forum_id to come from the forums table. -if ($db->sql_layer === 'firebird') -{ - $sql_array['SELECT'] = 'f.forum_id AS forum_id, ' . $sql_array['SELECT']; -} - // The FROM-Order is quite important here, else t.* columns can not be correctly bound. if ($post_id) { @@ -247,26 +226,8 @@ else $sql_array['WHERE'] = "p.post_id = $post_id AND t.topic_id = p.topic_id"; } -$sql_array['WHERE'] .= ' AND (f.forum_id = t.forum_id'; +$sql_array['WHERE'] .= ' AND f.forum_id = t.forum_id'; -if (!$forum_id) -{ - // If it is a global announcement make sure to set the forum id to a postable forum - $sql_array['WHERE'] .= ' OR (t.topic_type = ' . POST_GLOBAL . ' - AND f.forum_type = ' . FORUM_POST . ')'; -} -else -{ - $sql_array['WHERE'] .= ' OR (t.topic_type = ' . POST_GLOBAL . " - AND f.forum_id = $forum_id)"; -} - -$sql_array['WHERE'] .= ')'; - -// Join to forum table on topic forum_id unless topic forum_id is zero -// whereupon we join on the forum_id passed as a parameter ... this -// is done so navigation, forum name, etc. remain consistent with where -// user clicked to view a global topic $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); $topic_data = $db->sql_fetchrow($result); @@ -1540,7 +1501,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'U_REPORT' => ($auth->acl_get('f_report', $forum_id)) ? append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&p=' . $row['post_id']) : '', 'U_MCP_REPORT' => ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', 'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', - 'U_MINI_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . (($topic_data['topic_type'] == POST_GLOBAL) ? '&f=' . $forum_id : '') . '#p' . $row['post_id'], + 'U_MINI_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . '#p' . $row['post_id'], 'U_NEXT_POST_ID' => ($i < $i_total && isset($rowset[$post_list[$i + 1]])) ? $rowset[$post_list[$i + 1]]['post_id'] : '', 'U_PREV_POST_ID' => $prev_post_id, 'U_NOTES' => ($auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $poster_id, true, $user->session_id) : '', @@ -1616,34 +1577,13 @@ if (isset($user->data['session_page']) && !$user->data['is_bot'] && (strpos($use } } -// Get last post time for all global announcements -// to keep proper forums tracking -if ($topic_data['topic_type'] == POST_GLOBAL) -{ - $sql = 'SELECT topic_last_post_time as forum_last_post_time - FROM ' . TOPICS_TABLE . ' - WHERE forum_id = 0 - ORDER BY topic_last_post_time DESC'; - $result = $db->sql_query_limit($sql, 1); - $topic_data['forum_last_post_time'] = (int) $db->sql_fetchfield('forum_last_post_time'); - $db->sql_freeresult($result); - - $sql = 'SELECT mark_time as forum_mark_time - FROM ' . FORUMS_TRACK_TABLE . ' - WHERE forum_id = 0 - AND user_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - $topic_data['forum_mark_time'] = (int) $db->sql_fetchfield('forum_mark_time'); - $db->sql_freeresult($result); -} - // Only mark topic if it's currently unread. Also make sure we do not set topic tracking back if earlier pages are viewed. if (isset($topic_tracking_info[$topic_id]) && $topic_data['topic_last_post_time'] > $topic_tracking_info[$topic_id] && $max_post_time > $topic_tracking_info[$topic_id]) { - markread('topic', (($topic_data['topic_type'] == POST_GLOBAL) ? 0 : $forum_id), $topic_id, $max_post_time); + markread('topic', $forum_id, $topic_id, $max_post_time); // Update forum info - $all_marked_read = update_forum_tracking_info((($topic_data['topic_type'] == POST_GLOBAL) ? 0 : $forum_id), $topic_data['forum_last_post_time'], (isset($topic_data['forum_mark_time'])) ? $topic_data['forum_mark_time'] : false, false); + $all_marked_read = update_forum_tracking_info($forum_id, $topic_data['forum_last_post_time'], (isset($topic_data['forum_mark_time'])) ? $topic_data['forum_mark_time'] : false, false); } else { From 27fdcb4c7ec4aac68ba0a809473312ee83b50a66 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Mar 2010 16:03:14 +0100 Subject: [PATCH 135/170] [ticket/9684] Remove code in some more files especially includes/ Topic-Tracking is still missing. PHPBB3-9684 --- phpBB/download/file.php | 3 +- phpBB/includes/acp/acp_search.php | 5 +- phpBB/includes/functions_admin.php | 25 +--- phpBB/includes/functions_display.php | 20 --- phpBB/includes/functions_posting.php | 200 ++++----------------------- phpBB/includes/mcp/mcp_forum.php | 8 +- phpBB/includes/mcp/mcp_front.php | 39 ++---- phpBB/includes/mcp/mcp_main.php | 24 +--- phpBB/includes/mcp/mcp_queue.php | 61 +++----- phpBB/includes/mcp/mcp_reports.php | 11 +- phpBB/includes/ucp/ucp_main.php | 32 ++--- phpBB/memberlist.php | 2 +- phpBB/viewforum.php | 8 +- 13 files changed, 87 insertions(+), 351 deletions(-) diff --git a/phpBB/download/file.php b/phpBB/download/file.php index 5016e7f549..d33a50c149 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -194,8 +194,7 @@ else $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - // Global announcement? - $f_download = (!$row) ? $auth->acl_getf_global('f_download') : $auth->acl_get('f_download', $row['forum_id']); + $f_download = $auth->acl_get('f_download', $row['forum_id']); if ($auth->acl_get('u_download') && $f_download) { diff --git a/phpBB/includes/acp/acp_search.php b/phpBB/includes/acp/acp_search.php index 21f7e3d31b..a3061ae2da 100644 --- a/phpBB/includes/acp/acp_search.php +++ b/phpBB/includes/acp/acp_search.php @@ -397,9 +397,8 @@ class acp_search $i = 0; while ($row = ($buffer ? $rows[$i++] : $db->sql_fetchrow($result))) { - // Indexing enabled for this forum or global announcement? - // Global announcements get indexed by default. - if (!$row['forum_id'] || (isset($forums[$row['forum_id']]) && $forums[$row['forum_id']])) + // Indexing enabled for this forum + if (isset($forums[$row['forum_id']]) && $forums[$row['forum_id']]) { $this->search->index('post', $row['post_id'], $row['post_text'], $row['post_subject'], $row['poster_id'], $row['forum_id']); } diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 1468345003..ee59d77cdb 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2208,6 +2208,7 @@ function prune($forum_id, $prune_mode, $prune_date, $prune_flags = 0, $auto_sync if (!($prune_flags & FORUM_FLAG_PRUNE_ANNOUNCE)) { $sql_and .= ' AND topic_type <> ' . POST_ANNOUNCE; + $sql_and .= ' AND topic_type <> ' . POST_GLOBAL; } if (!($prune_flags & FORUM_FLAG_PRUNE_STICKY)) @@ -2695,29 +2696,9 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id while ($row = $db->sql_fetchrow($result)) { - if (!$row['forum_id']) + if ($auth->acl_get('f_read', $row['forum_id'])) { - if ($auth->acl_getf_global('f_read')) - { - if (!$default_forum_id) - { - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_type = ' . FORUM_POST; - $f_result = $db->sql_query_limit($sql, 1); - $default_forum_id = (int) $db->sql_fetchfield('forum_id', false, $f_result); - $db->sql_freeresult($f_result); - } - - $is_auth[$row['topic_id']] = $default_forum_id; - } - } - else - { - if ($auth->acl_get('f_read', $row['forum_id'])) - { - $is_auth[$row['topic_id']] = $row['forum_id']; - } + $is_auth[$row['topic_id']] = $row['forum_id']; } if ($auth->acl_gets('a_', 'm_', $row['forum_id'])) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 6314ba0ec9..abc5b3e29f 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -104,18 +104,6 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $forum_tracking_info = array(); $branch_root_id = $root_data['forum_id']; - // Check for unread global announcements (index page only) - $ga_unread = false; - if ($root_data['forum_id'] == 0) - { - $unread_ga_list = get_unread_topics($user->data['user_id'], 'AND t.forum_id = 0', '', 1); - - if (!empty($unread_ga_list)) - { - $ga_unread = true; - } - } - while ($row = $db->sql_fetchrow($result)) { $forum_id = $row['forum_id']; @@ -269,8 +257,6 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod } else { - // Add 0 to forums array to mark global announcements correctly - $forum_ids[] = 0; markread('topics', $forum_ids); $message = sprintf($user->lang['RETURN_FORUM'], '', ''); } @@ -323,12 +309,6 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $forum_unread = (isset($forum_tracking_info[$forum_id]) && $row['orig_forum_last_post_time'] > $forum_tracking_info[$forum_id]) ? true : false; - // Mark the first visible forum on index as unread if there's any unread global announcement - if ($ga_unread && !empty($forum_ids_moderator) && $forum_id == $forum_ids_moderator[0]) - { - $forum_unread = true; - } - $folder_image = $folder_alt = $l_subforums = ''; $subforums_list = array(); diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 61cc096e26..3f6dbfa41f 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -338,7 +338,7 @@ function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL) $topic_type_array[] = array( 'VALUE' => $topic_value['const'], - 'S_CHECKED' => ($cur_topic_type == $topic_value['const'] || ($forum_id == 0 && $topic_value['const'] == POST_GLOBAL)) ? ' checked="checked"' : '', + 'S_CHECKED' => ($cur_topic_type == $topic_value['const']) ? ' checked="checked"' : '', 'L_TOPIC_TYPE' => $user->lang[$topic_value['lang']] ); } @@ -1465,11 +1465,8 @@ function delete_post($forum_id, $topic_id, $post_id, &$data) delete_topics('topic_id', array($topic_id), false); - if ($data['topic_type'] != POST_GLOBAL) - { - $sql_data[FORUMS_TABLE] .= 'forum_topics_real = forum_topics_real - 1'; - $sql_data[FORUMS_TABLE] .= ($data['topic_approved']) ? ', forum_posts = forum_posts - 1, forum_topics = forum_topics - 1' : ''; - } + $sql_data[FORUMS_TABLE] .= 'forum_topics_real = forum_topics_real - 1'; + $sql_data[FORUMS_TABLE] .= ($data['topic_approved']) ? ', forum_posts = forum_posts - 1, forum_topics = forum_topics - 1' : ''; $update_sql = update_post_information('forum', $forum_id, true); if (sizeof($update_sql)) @@ -1489,10 +1486,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data) $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - if ($data['topic_type'] != POST_GLOBAL) - { - $sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : ''; - } + $sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : ''; $sql_data[TOPICS_TABLE] = 'topic_poster = ' . intval($row['poster_id']) . ', topic_first_post_id = ' . intval($row['post_id']) . ", topic_first_poster_colour = '" . $db->sql_escape($row['user_colour']) . "', topic_first_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "', topic_time = " . (int) $row['post_time']; @@ -1503,10 +1497,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data) break; case 'delete_last_post': - if ($data['topic_type'] != POST_GLOBAL) - { - $sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : ''; - } + $sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : ''; $update_sql = update_post_information('forum', $forum_id, true); if (sizeof($update_sql)) @@ -1548,10 +1539,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data) $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - if ($data['topic_type'] != POST_GLOBAL) - { - $sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : ''; - } + $sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : ''; $sql_data[TOPICS_TABLE] = 'topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : ''); $next_post_id = (int) $row['post_id']; @@ -1703,7 +1691,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u case 'post': case 'reply': $sql_data[POSTS_TABLE]['sql'] = array( - 'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'], + 'forum_id' => $data['forum_id'], 'poster_id' => (int) $user->data['user_id'], 'icon_id' => $data['icon_id'], 'poster_ip' => $user->ip, @@ -1771,7 +1759,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } $sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array( - 'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'], + 'forum_id' => $data['forum_id'], 'poster_id' => $data['poster_id'], 'icon_id' => $data['icon_id'], 'post_approved' => (!$post_approval) ? 0 : $data['post_approved'], @@ -1807,7 +1795,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u 'topic_poster' => (int) $user->data['user_id'], 'topic_time' => $current_time, 'topic_last_view_time' => $current_time, - 'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'], + 'forum_id' => $data['forum_id'], 'icon_id' => $data['icon_id'], 'topic_approved' => $post_approval, 'topic_title' => $subject, @@ -1843,14 +1831,11 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = $current_time" . (($auth->acl_get('f_postcount', $data['forum_id']) && $post_approval) ? ', user_posts = user_posts + 1' : ''); - if ($topic_type != POST_GLOBAL) + if ($post_approval) { - if ($post_approval) - { - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts + 1'; - } - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_real = forum_topics_real + 1' . (($post_approval) ? ', forum_topics = forum_topics + 1' : ''); + $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts + 1'; } + $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_real = forum_topics_real + 1' . (($post_approval) ? ', forum_topics = forum_topics + 1' : ''); break; case 'reply': @@ -1863,7 +1848,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = $current_time" . (($auth->acl_get('f_postcount', $data['forum_id']) && $post_approval) ? ', user_posts = user_posts + 1' : ''); - if ($post_approval && $topic_type != POST_GLOBAL) + if ($post_approval) { $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts + 1'; } @@ -1887,7 +1872,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } $sql_data[TOPICS_TABLE]['sql'] = array( - 'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'], + 'forum_id' => $data['forum_id'], 'icon_id' => $data['icon_id'], 'topic_approved' => (!$post_approval) ? 0 : $data['topic_approved'], 'topic_title' => $subject, @@ -2002,61 +1987,6 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u unset($sql_data[POSTS_TABLE]['sql']); } - $make_global = false; - - // Are we globalising or unglobalising? - if ($post_mode == 'edit_first_post' || $post_mode == 'edit_topic') - { - if (!sizeof($topic_row)) - { - $sql = 'SELECT topic_type, topic_replies, topic_replies_real, topic_approved, topic_last_post_id - FROM ' . TOPICS_TABLE . ' - WHERE topic_id = ' . $data['topic_id']; - $result = $db->sql_query($sql); - $topic_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - } - - // globalise/unglobalise? - if (($topic_row['topic_type'] != POST_GLOBAL && $topic_type == POST_GLOBAL) || ($topic_row['topic_type'] == POST_GLOBAL && $topic_type != POST_GLOBAL)) - { - if (!empty($sql_data[FORUMS_TABLE]['stat']) && implode('', $sql_data[FORUMS_TABLE]['stat'])) - { - $db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET ' . implode(', ', $sql_data[FORUMS_TABLE]['stat']) . ' WHERE forum_id = ' . $data['forum_id']); - } - - $make_global = true; - $sql_data[FORUMS_TABLE]['stat'] = array(); - } - - // globalise - if ($topic_row['topic_type'] != POST_GLOBAL && $topic_type == POST_GLOBAL) - { - // Decrement topic/post count - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts - ' . ($topic_row['topic_replies_real'] + 1); - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_real = forum_topics_real - 1' . (($topic_row['topic_approved']) ? ', forum_topics = forum_topics - 1' : ''); - - // Update forum_ids for all posts - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET forum_id = 0 - WHERE topic_id = ' . $data['topic_id']; - $db->sql_query($sql); - } - // unglobalise - else if ($topic_row['topic_type'] == POST_GLOBAL && $topic_type != POST_GLOBAL) - { - // Increment topic/post count - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts + ' . ($topic_row['topic_replies_real'] + 1); - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_real = forum_topics_real + 1' . (($topic_row['topic_approved']) ? ', forum_topics = forum_topics + 1' : ''); - - // Update forum_ids for all posts - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET forum_id = ' . $data['forum_id'] . ' - WHERE topic_id = ' . $data['topic_id']; - $db->sql_query($sql); - } - } - // Update the topics table if (isset($sql_data[TOPICS_TABLE]['sql'])) { @@ -2219,9 +2149,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } // we need to update the last forum information - // only applicable if the topic is not global and it is approved - // we also check to make sure we are not dealing with globaling the latest topic (pretty rare but still needs to be checked) - if ($topic_type != POST_GLOBAL && !$make_global && ($post_approved || !$data['post_approved'])) + // only applicable if the topic is approved + if ($post_approved || !$data['post_approved']) { // the last post makes us update the forum table. This can happen if... // We make a new topic @@ -2311,78 +2240,6 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } } } - else if ($make_global) - { - // somebody decided to be a party pooper, we must recalculate the whole shebang (maybe) - $sql = 'SELECT forum_last_post_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . (int) $data['forum_id']; - $result = $db->sql_query($sql); - $forum_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // we made a topic global, go get new data - if ($topic_row['topic_type'] != POST_GLOBAL && $topic_type == POST_GLOBAL && $forum_row['forum_last_post_id'] == $topic_row['topic_last_post_id']) - { - // we need a fresh change of socks, everything has become invalidated - $sql = 'SELECT MAX(topic_last_post_id) as last_post_id - FROM ' . TOPICS_TABLE . ' - WHERE forum_id = ' . (int) $data['forum_id'] . ' - AND topic_approved = 1'; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // any posts left in this forum? - if (!empty($row['last_post_id'])) - { - $sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.user_id, u.username, u.user_colour - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u - WHERE p.poster_id = u.user_id - AND p.post_id = ' . (int) $row['last_post_id']; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // salvation, a post is found! jam it into the forums table - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . (int) $row['post_id']; - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . $db->sql_escape($row['post_subject']) . "'"; - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = ' . (int) $row['post_time']; - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = ' . (int) $row['poster_id']; - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape(($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username']) . "'"; - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . $db->sql_escape($row['user_colour']) . "'"; - } - else - { - // just our luck, the last topic in the forum has just been globalized... - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = 0'; - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = ''"; - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = 0'; - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = 0'; - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = ''"; - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = ''"; - } - } - else if ($topic_row['topic_type'] == POST_GLOBAL && $topic_type != POST_GLOBAL && $forum_row['forum_last_post_id'] < $topic_row['topic_last_post_id']) - { - // this post has a higher id, it is newer - $sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.user_id, u.username, u.user_colour - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u - WHERE p.poster_id = u.user_id - AND p.post_id = ' . (int) $topic_row['topic_last_post_id']; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // salvation, a post is found! jam it into the forums table - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . (int) $row['post_id']; - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . $db->sql_escape($row['post_subject']) . "'"; - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = ' . (int) $row['post_time']; - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = ' . (int) $row['poster_id']; - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape(($row['poster_id'] == ANONYMOUS) ? $row['post_username'] : $row['username']) . "'"; - $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . $db->sql_escape($row['user_colour']) . "'"; - } - } // topic sync time! // simply, we update if it is a reply or the last post is edited @@ -2470,7 +2327,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } // Delete topic shadows (if any exist). We do not need a shadow topic for an global announcement - if ($make_global) + if ($topic_type == POST_GLOBAL) { $sql = 'DELETE FROM ' . TOPICS_TABLE . ' WHERE topic_moved_id = ' . $data['topic_id']; @@ -2514,7 +2371,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u trigger_error($error); } - $search->index($mode, $data['post_id'], $data['message'], $subject, $poster_id, ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id']); + $search->index($mode, $data['post_id'], $data['message'], $subject, $poster_id, $data['forum_id']); } // Topic Notification, do not change if moderator is changing other users posts... @@ -2543,7 +2400,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u // Mark this topic as read // We do not use post_time here, this is intended (post_time can have a date in the past if editing a message) - markread('topic', (($topic_type == POST_GLOBAL) ? 0 : $data['forum_id']), $data['topic_id'], time()); + markread('topic', $data['forum_id'], $data['topic_id'], time()); // if ($config['load_db_lastread'] && $user->data['is_registered']) @@ -2551,7 +2408,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $sql = 'SELECT mark_time FROM ' . FORUMS_TRACK_TABLE . ' WHERE user_id = ' . $user->data['user_id'] . ' - AND forum_id = ' . (($topic_type == POST_GLOBAL) ? 0 : $data['forum_id']); + AND forum_id = ' . $data['forum_id']; $result = $db->sql_query($sql); $f_mark_time = (int) $db->sql_fetchfield('mark_time'); $db->sql_freeresult($result); @@ -2564,23 +2421,14 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u if (($config['load_db_lastread'] && $user->data['is_registered']) || $config['load_anon_lastread'] || $user->data['is_registered']) { // Update forum info - if ($topic_type == POST_GLOBAL) - { - $sql = 'SELECT MAX(topic_last_post_time) as forum_last_post_time - FROM ' . TOPICS_TABLE . ' - WHERE forum_id = 0'; - } - else - { - $sql = 'SELECT forum_last_post_time - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $data['forum_id']; - } + $sql = 'SELECT forum_last_post_time + FROM ' . FORUMS_TABLE . ' + WHERE forum_id = ' . $data['forum_id']; $result = $db->sql_query($sql); $forum_last_post_time = (int) $db->sql_fetchfield('forum_last_post_time'); $db->sql_freeresult($result); - update_forum_tracking_info((($topic_type == POST_GLOBAL) ? 0 : $data['forum_id']), $forum_last_post_time, $f_mark_time, false); + update_forum_tracking_info($data['forum_id'], $forum_last_post_time, $f_mark_time, false); } // Send Notifications diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index aad030a7d3..8d2b90cba9 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -150,10 +150,10 @@ function mcp_forum_view($id, $mode, $action, $forum_info) $read_tracking_join = $read_tracking_select = ''; } - $sql = "SELECT t.topic_id - FROM " . TOPICS_TABLE . " t - WHERE t.forum_id IN($forum_id, 0) - " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1') . " + $sql = 'SELECT t.topic_id + FROM ' . TOPICS_TABLE . ' t + WHERE t.forum_id = ' . $forum_id . ' + ' . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1') . " $limit_time_sql ORDER BY t.topic_type DESC, $sort_order_sql"; $result = $db->sql_query_limit($sql, $topics_per_page, $start); diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index 7375e20d96..eca67c5ac1 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -39,7 +39,7 @@ function mcp_front_view($id, $mode, $action) { $sql = 'SELECT COUNT(post_id) AS total FROM ' . POSTS_TABLE . ' - WHERE forum_id IN (0, ' . implode(', ', $forum_list) . ') + WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' AND post_approved = 0'; $result = $db->sql_query($sql); $total = (int) $db->sql_fetchfield('total'); @@ -47,8 +47,6 @@ function mcp_front_view($id, $mode, $action) if ($total) { - $global_id = $forum_list[0]; - $sql = 'SELECT forum_id, forum_name FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_list); @@ -62,7 +60,7 @@ function mcp_front_view($id, $mode, $action) $sql = 'SELECT post_id FROM ' . POSTS_TABLE . ' - WHERE forum_id IN (0, ' . implode(', ', $forum_list) . ') + WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' AND post_approved = 0 ORDER BY post_time DESC'; $result = $db->sql_query_limit($sql, 5); @@ -91,17 +89,11 @@ function mcp_front_view($id, $mode, $action) while ($row = $db->sql_fetchrow($result)) { - $global_topic = ($row['forum_id']) ? false : true; - if ($global_topic) - { - $row['forum_id'] = $global_id; - } - $template->assign_block_vars('unapproved', array( 'U_POST_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $row['forum_id'] . '&p=' . $row['post_id']), - 'U_MCP_FORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=forum_view&f=' . $row['forum_id']) : '', + 'U_MCP_FORUM' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=forum_view&f=' . $row['forum_id']), 'U_MCP_TOPIC' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=topic_view&f=' . $row['forum_id'] . '&t=' . $row['topic_id']), - 'U_FORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '', + 'U_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']), 'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']), 'AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour']), @@ -109,7 +101,7 @@ function mcp_front_view($id, $mode, $action) 'AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour']), 'U_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour']), - 'FORUM_NAME' => (!$global_topic) ? $forum_names[$row['forum_id']] : $user->lang['GLOBAL_ANNOUNCEMENT'], + 'FORUM_NAME' => $forum_names[$row['forum_id']], 'POST_ID' => $row['post_id'], 'TOPIC_TITLE' => $row['topic_title'], 'SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'], @@ -159,15 +151,13 @@ function mcp_front_view($id, $mode, $action) WHERE r.post_id = p.post_id AND r.pm_id = 0 AND r.report_closed = 0 - AND p.forum_id IN (0, ' . implode(', ', $forum_list) . ')'; + AND ' . $db->sql_in_set('p.forum_id', $forum_list); $result = $db->sql_query($sql); $total = (int) $db->sql_fetchfield('total'); $db->sql_freeresult($result); if ($total) { - $global_id = $forum_list[0]; - $sql = $db->sql_build_query('SELECT', array( 'SELECT' => 'r.report_time, p.post_id, p.post_subject, p.post_time, u.username, u.username_clean, u.user_colour, u.user_id, u2.username as author_name, u2.username_clean as author_name_clean, u2.user_colour as author_colour, u2.user_id as author_id, t.topic_id, t.topic_title, f.forum_id, f.forum_name', @@ -193,7 +183,7 @@ function mcp_front_view($id, $mode, $action) AND p.topic_id = t.topic_id AND r.user_id = u.user_id AND p.poster_id = u2.user_id - AND p.forum_id IN (0, ' . implode(', ', $forum_list) . ')', + AND ' . $db->sql_in_set('p.forum_id', $forum_list), 'ORDER_BY' => 'p.post_time DESC' )); @@ -201,17 +191,11 @@ function mcp_front_view($id, $mode, $action) while ($row = $db->sql_fetchrow($result)) { - $global_topic = ($row['forum_id']) ? false : true; - if ($global_topic) - { - $row['forum_id'] = $global_id; - } - $template->assign_block_vars('report', array( 'U_POST_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['post_id'] . "&i=reports&mode=report_details"), - 'U_MCP_FORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . "&i=$id&mode=forum_view") : '', + 'U_MCP_FORUM' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . "&i=$id&mode=forum_view"), 'U_MCP_TOPIC' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id'] . "&i=$id&mode=topic_view"), - 'U_FORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '', + 'U_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']), 'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']), 'REPORTER_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), @@ -224,7 +208,7 @@ function mcp_front_view($id, $mode, $action) 'AUTHOR_COLOUR' => get_username_string('colour', $row['author_id'], $row['author_name'], $row['author_colour']), 'U_AUTHOR' => get_username_string('profile', $row['author_id'], $row['author_name'], $row['author_colour']), - 'FORUM_NAME' => (!$global_topic) ? $row['forum_name'] : $user->lang['GLOBAL_ANNOUNCEMENT'], + 'FORUM_NAME' => $row['forum_name'], 'TOPIC_TITLE' => $row['topic_title'], 'SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'REPORT_TIME' => $user->format_date($row['report_time']), @@ -347,9 +331,6 @@ function mcp_front_view($id, $mode, $action) if (!empty($forum_list)) { - // Add forum_id 0 for global announcements - $forum_list[] = 0; - $log_count = false; $log = array(); view_log('mod', $log, $log_count, 5, 0, $forum_list); diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index b9964f48a7..212c8dcdaf 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -485,16 +485,13 @@ function mcp_move_topic($topic_ids) $topic_posts_added += $topic_info['topic_replies']; - if ($topic_info['topic_type'] != POST_GLOBAL) - { - $topics_removed++; - $topic_posts_removed += $topic_info['topic_replies']; + $topics_removed++; + $topic_posts_removed += $topic_info['topic_replies']; - if ($topic_info['topic_approved']) - { - $topics_authed_removed++; - $topic_posts_removed++; - } + if ($topic_info['topic_approved']) + { + $topics_authed_removed++; + $topic_posts_removed++; } } @@ -532,15 +529,6 @@ function mcp_move_topic($topic_ids) $forum_ids[] = $row['forum_id']; add_log('mod', $to_forum_id, $topic_id, 'LOG_MOVE', $row['forum_name'], $forum_data['forum_name']); - // If we have moved a global announcement, we need to correct the topic type - if ($row['topic_type'] == POST_GLOBAL) - { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_type = ' . POST_ANNOUNCE . ' - WHERE topic_id = ' . (int) $row['topic_id']; - $db->sql_query($sql); - } - // Leave a redirection if required and only if the topic is visible to users if ($leave_shadow && $row['topic_approved'] && $row['topic_type'] != POST_GLOBAL) { diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index a5e0e426be..0630f55b12 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -268,13 +268,11 @@ class mcp_queue trigger_error('NOT_MODERATOR'); } - $global_id = $forum_list[0]; - $forum_list = implode(', ', $forum_list); $sql = 'SELECT SUM(forum_topics) as sum_forum_topics - FROM ' . FORUMS_TABLE . " - WHERE forum_id IN (0, $forum_list)"; + FROM ' . FORUMS_TABLE . ' + WHERE ' . $db->sql_in_set('forum_id', $forum_list); $result = $db->sql_query($sql); $forum_info['forum_topics'] = (int) $db->sql_fetchfield('sum_forum_topics'); $db->sql_freeresult($result); @@ -290,7 +288,6 @@ class mcp_queue $forum_info = $forum_info[$forum_id]; $forum_list = $forum_id; - $global_id = $forum_id; } $forum_options = ''; @@ -312,10 +309,10 @@ class mcp_queue if ($mode == 'unapproved_posts') { $sql = 'SELECT p.post_id - FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . " - WHERE p.forum_id IN (0, $forum_list) + FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . ' + WHERE ' . $db->sql_in_set('p.forum_id', $forum_list) . ' AND p.post_approved = 0 - " . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . ' + ' . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . ' ' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . " AND t.topic_id = p.topic_id AND t.topic_first_post_id <> p.post_id @@ -345,10 +342,7 @@ class mcp_queue $post_data = $rowset = array(); while ($row = $db->sql_fetchrow($result)) { - if ($row['forum_id']) - { - $forum_names[] = $row['forum_id']; - } + $forum_names[] = $row['forum_id']; $post_data[$row['post_id']] = $row; } $db->sql_freeresult($result); @@ -368,7 +362,7 @@ class mcp_queue { $sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, t.topic_title AS post_subject, t.topic_time AS post_time, t.topic_poster AS poster_id, t.topic_first_post_id AS post_id, t.topic_first_poster_name AS username, t.topic_first_poster_colour AS user_colour FROM ' . TOPICS_TABLE . " t - WHERE forum_id IN (0, $forum_list) + WHERE " . $db->sql_in_set('forum_id', $forum_list) . " AND topic_approved = 0 $limit_time_sql ORDER BY $sort_order_sql"; @@ -377,10 +371,7 @@ class mcp_queue $rowset = array(); while ($row = $db->sql_fetchrow($result)) { - if ($row['forum_id']) - { - $forum_names[] = $row['forum_id']; - } + $forum_names[] = $row['forum_id']; $rowset[] = $row; } $db->sql_freeresult($result); @@ -404,12 +395,6 @@ class mcp_queue foreach ($rowset as $row) { - $global_topic = ($row['forum_id']) ? false : true; - if ($global_topic) - { - $row['forum_id'] = $global_id; - } - if (empty($row['post_username'])) { $row['post_username'] = $user->lang['GUEST']; @@ -417,7 +402,7 @@ class mcp_queue $template->assign_block_vars('postrow', array( 'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']), - 'U_VIEWFORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '', + 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']), 'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['post_id']) . (($mode == 'unapproved_posts') ? '#p' . $row['post_id'] : ''), 'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&start=$start&mode=approve_details&f={$row['forum_id']}&p={$row['post_id']}" . (($mode == 'unapproved_topics') ? "&t={$row['topic_id']}" : '')), @@ -427,7 +412,7 @@ class mcp_queue 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_ID' => $row['post_id'], - 'FORUM_NAME' => (!$global_topic) ? $forum_names[$row['forum_id']] : $user->lang['GLOBAL_ANNOUNCEMENT'], + 'FORUM_NAME' => $forum_names[$row['forum_id']], 'POST_SUBJECT' => ($row['post_subject'] != '') ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'TOPIC_TITLE' => $row['topic_title'], 'POST_TIME' => $user->format_date($row['post_time'])) @@ -504,11 +489,7 @@ function approve_post($post_id_list, $id, $mode) } $topic_id_list[$post_data['topic_id']] = 1; - - if ($post_data['forum_id']) - { - $forum_id_list[$post_data['forum_id']] = 1; - } + $forum_id_list[$post_data['forum_id']] = 1; // User post update (we do not care about topic or post, since user posts are strictly connected to posts) // But we care about forums where post counts get not increased. ;) @@ -520,10 +501,7 @@ function approve_post($post_id_list, $id, $mode) // Topic or Post. ;) if ($post_data['topic_first_post_id'] == $post_id) { - if ($post_data['forum_id']) - { - $total_topics++; - } + $total_topics++; $topic_approve_sql[] = $post_data['topic_id']; $approve_log[] = array( @@ -543,16 +521,13 @@ function approve_post($post_id_list, $id, $mode) ); } - if ($post_data['forum_id']) - { - $total_posts++; + $total_posts++; - // Increment by topic_replies if we approve a topic... - // This works because we do not adjust the topic_replies when re-approving a topic after an edit. - if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_replies']) - { - $total_posts += $post_data['topic_replies']; - } + // Increment by topic_replies if we approve a topic... + // This works because we do not adjust the topic_replies when re-approving a topic after an edit. + if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_replies']) + { + $total_posts += $post_data['topic_replies']; } $post_approve_sql[] = $post_id; diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index f6e46b57ee..a7275382e6 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -312,7 +312,6 @@ class mcp_reports $forum_info = $forum_info[$forum_id]; $forum_list = array($forum_id); - $global_id = $forum_id; } $forum_list[] = 0; @@ -382,14 +381,8 @@ class mcp_reports $report_data = $rowset = array(); while ($row = $db->sql_fetchrow($result)) { - $global_topic = ($row['forum_id']) ? false : true; - if ($global_topic) - { - $row['forum_id'] = $global_id; - } - $template->assign_block_vars('postrow', array( - 'U_VIEWFORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '', + 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']), 'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['post_id']) . '#p' . $row['post_id'], 'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=reports&start=$start&mode=report_details&f={$row['forum_id']}&r={$row['report_id']}"), @@ -403,7 +396,7 @@ class mcp_reports 'REPORTER' => get_username_string('username', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'U_REPORTER' => get_username_string('profile', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), - 'FORUM_NAME' => (!$global_topic) ? $forum_data[$row['forum_id']]['forum_name'] : $user->lang['GLOBAL_ANNOUNCEMENT'], + 'FORUM_NAME' => $forum_data[$row['forum_id']]['forum_name'], 'POST_ID' => $row['post_id'], 'POST_SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'POST_TIME' => $user->format_date($row['post_time']), diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php index 249c8e5750..3a1d7e4351 100644 --- a/phpBB/includes/ucp/ucp_main.php +++ b/phpBB/includes/ucp/ucp_main.php @@ -63,32 +63,19 @@ class ucp_main $folder = 'global_read'; $folder_new = 'global_unread'; - // Get cleaned up list... return only those forums not having the f_read permission - $forum_ary = $auth->acl_getf('!f_read', true); + // Get cleaned up list... return only those forums having the f_read permission + $forum_ary = $auth->acl_getf('f_read', true); $forum_ary = array_unique(array_keys($forum_ary)); - // Determine first forum the user is able to read into - for global announcement link - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_type = ' . FORUM_POST; - - if (sizeof($forum_ary)) - { - $sql .= ' AND ' . $db->sql_in_set('forum_id', $forum_ary, true); - } - $result = $db->sql_query_limit($sql, 1); - $g_forum_id = (int) $db->sql_fetchfield('forum_id'); - $db->sql_freeresult($result); - $sql = "SELECT t.* $sql_select FROM $sql_from - WHERE t.forum_id = 0 - AND t.topic_type = " . POST_GLOBAL . ' + WHERE t.topic_type = " . POST_GLOBAL . ' + AND ' . $db->sql_in_set('t.forum_id', $forum_ary) . ' ORDER BY t.topic_last_post_time DESC'; $topic_list = $rowset = array(); // If the user can't see any forums, he can't read any posts because fid of 0 is invalid - if ($g_forum_id) + if (!empty($forum_ary)) { $result = $db->sql_query($sql); @@ -158,10 +145,10 @@ class ucp_main 'S_UNREAD' => $unread_topic, 'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), - 'U_LAST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$g_forum_id&t=$topic_id&p=" . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'], + 'U_LAST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&p=" . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'], 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), - 'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$g_forum_id&t=$topic_id&view=unread") . '#unread', - 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$g_forum_id&t=$topic_id")) + 'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&view=unread") . '#unread', + 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id")) ); } @@ -805,9 +792,8 @@ class ucp_main 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'S_DELETED_TOPIC' => (!$row['topic_id']) ? true : false, - 'S_GLOBAL_TOPIC' => (!$forum_id) ? true : false, - 'PAGINATION' => topic_generate_pagination($replies, append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($row['forum_id']) ? $row['forum_id'] : $forum_id) . "&t=$topic_id")), + 'PAGINATION' => topic_generate_pagination($replies, append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . "&t=$topic_id")), 'REPLIES' => $replies, 'VIEWS' => $row['topic_views'], 'TOPIC_TITLE' => censor_text($row['topic_title']), diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 64d29d18bd..685830c656 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1136,7 +1136,7 @@ switch ($mode) $sql = 'SELECT DISTINCT poster_id FROM ' . POSTS_TABLE . ' WHERE poster_ip ' . ((strpos($ips, '%') !== false) ? 'LIKE' : 'IN') . " ($ips) - AND forum_id IN (" . implode(', ', $ip_forums) . ')'; + AND " . $db->sql_in_set('forum_id', $ip_forums); $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index ebf2dc3501..fbc4d63405 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -359,6 +359,10 @@ if ($user->data['is_registered']) if ($forum_data['forum_type'] == FORUM_POST) { + // Get global announcement forums + $g_forum_ary = $auth->acl_getf('f_read', true); + $g_forum_ary = array_unique(array_keys($g_forum_ary)); + // Obtain announcements ... removed sort ordering, sort by time in all cases $sql = $db->sql_build_query('SELECT', array( 'SELECT' => $sql_array['SELECT'], @@ -366,7 +370,9 @@ if ($forum_data['forum_type'] == FORUM_POST) 'LEFT_JOIN' => $sql_array['LEFT_JOIN'], 'WHERE' => '(t.forum_id = ' . $forum_id . ' - AND t.topic_type = ' . POST_ANNOUNCE . ') OR t.topic_type = ' . POST_GLOBAL, + AND t.topic_type = ' . POST_ANNOUNCE . ') OR + (' . $db->sql_in_set('t.forum_id', $g_forum_ary) . ' + AND t.topic_type = ' . POST_GLOBAL . ')', 'ORDER_BY' => 't.topic_time DESC', )); From 9265ffbcd5c4cff9c9e4e775d7d8d4877b86fbb8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Mar 2010 23:36:47 +0100 Subject: [PATCH 136/170] [ticket/9684] Fix a SQL-Error in the posting.php PHPBB3-9684 --- phpBB/posting.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/posting.php b/phpBB/posting.php index 2fcfd126eb..734e97742c 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -88,7 +88,7 @@ switch ($mode) FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f WHERE t.topic_id = $topic_id AND f.forum_id = t.forum_id" . - (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1'); + (($auth->acl_get('m_approve', $forum_id)) ? '' : ' AND t.topic_approved = 1'); break; case 'quote': @@ -116,7 +116,7 @@ switch ($mode) AND t.topic_id = p.topic_id AND u.user_id = p.poster_id AND f.forum_id = t.forum_id" . - (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND p.post_approved = 1'); + (($auth->acl_get('m_approve', $forum_id)) ? '' : ' AND p.post_approved = 1'); break; case 'smilies': From 712a51caeadef42eff9131ed2e97ee2ab5291888 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Mar 2010 23:53:40 +0100 Subject: [PATCH 137/170] [ticket/9684] Fix Forum/Topic-Tracking for global announcements Should be ready for intensive testing now. PHPBB3-9684 --- phpBB/includes/functions.php | 66 ++---------------------- phpBB/includes/mcp/mcp_forum.php | 4 +- phpBB/includes/ucp/ucp_main.php | 33 ++++++++++-- phpBB/search.php | 4 +- phpBB/viewforum.php | 87 ++++++++++++++++++++------------ 5 files changed, 90 insertions(+), 104 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index f910611b76..0638cfccb6 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1323,35 +1323,6 @@ function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time, $ { $mark_time = array(); - // Get global announcement info - if ($global_announce_list && sizeof($global_announce_list)) - { - if (!isset($forum_mark_time[0])) - { - global $db; - - $sql = 'SELECT mark_time - FROM ' . FORUMS_TRACK_TABLE . " - WHERE user_id = {$user->data['user_id']} - AND forum_id = 0"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $mark_time[0] = $row['mark_time']; - } - } - else - { - if ($forum_mark_time[0] !== false) - { - $mark_time[0] = $forum_mark_time[0]; - } - } - } - if (!empty($forum_mark_time[$forum_id]) && $forum_mark_time[$forum_id] !== false) { $mark_time[$forum_id] = $forum_mark_time[$forum_id]; @@ -1361,14 +1332,7 @@ function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time, $ foreach ($topic_ids as $topic_id) { - if ($global_announce_list && isset($global_announce_list[$topic_id])) - { - $last_read[$topic_id] = (isset($mark_time[0])) ? $mark_time[0] : $user_lastmark; - } - else - { - $last_read[$topic_id] = $user_lastmark; - } + $last_read[$topic_id] = $user_lastmark; } } @@ -1412,8 +1376,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis $sql = 'SELECT forum_id, mark_time FROM ' . FORUMS_TRACK_TABLE . " WHERE user_id = {$user->data['user_id']} - AND forum_id " . - (($global_announce_list && sizeof($global_announce_list)) ? "IN (0, $forum_id)" : "= $forum_id"); + AND forum_id = $forum_id"; $result = $db->sql_query($sql); $mark_time = array(); @@ -1427,14 +1390,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis foreach ($topic_ids as $topic_id) { - if ($global_announce_list && isset($global_announce_list[$topic_id])) - { - $last_read[$topic_id] = (isset($mark_time[0])) ? $mark_time[0] : $user_lastmark; - } - else - { - $last_read[$topic_id] = $user_lastmark; - } + $last_read[$topic_id] = $user_lastmark; } } } @@ -1472,13 +1428,6 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis if (sizeof($topic_ids)) { $mark_time = array(); - if ($global_announce_list && sizeof($global_announce_list)) - { - if (isset($tracking_topics['f'][0])) - { - $mark_time[0] = base_convert($tracking_topics['f'][0], 36, 10) + $config['board_startdate']; - } - } if (isset($tracking_topics['f'][$forum_id])) { @@ -1489,14 +1438,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis foreach ($topic_ids as $topic_id) { - if ($global_announce_list && isset($global_announce_list[$topic_id])) - { - $last_read[$topic_id] = (isset($mark_time[0])) ? $mark_time[0] : $user_lastmark; - } - else - { - $last_read[$topic_id] = $user_lastmark; - } + $last_read[$topic_id] = $user_lastmark; } } } diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index 8d2b90cba9..f170dd68eb 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -188,11 +188,11 @@ function mcp_forum_view($id, $mode, $action, $forum_info) { if ($config['load_db_lastread']) { - $topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $topic_rows, array($forum_id => $forum_info['mark_time']), array()); + $topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $topic_rows, array($forum_id => $forum_info['mark_time'])); } else { - $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list, array()); + $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list); } } diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php index 3a1d7e4351..f4fdb50ecd 100644 --- a/phpBB/includes/ucp/ucp_main.php +++ b/phpBB/includes/ucp/ucp_main.php @@ -57,6 +57,10 @@ class ucp_main $sql_from .= ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id'] . ')'; $sql_select .= ', tt.mark_time'; + + $sql_from .= ' LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.forum_id = t.forum_id + AND ft.user_id = ' . $user->data['user_id'] . ')'; + $sql_select .= ', ft.mark_time AS forum_mark_time'; } $topic_type = $user->lang['VIEW_TOPIC_GLOBAL']; @@ -87,15 +91,34 @@ class ucp_main $db->sql_freeresult($result); } - $topic_tracking_info = array(); + $topic_forum_list = array(); + foreach ($rowset as $t_id => $row) + { + if (isset($forum_tracking_info[$row['forum_id']])) + { + $row['forum_mark_time'] = $forum_tracking_info[$row['forum_id']]; + } + + $topic_forum_list[$row['forum_id']]['forum_mark_time'] = ($config['load_db_lastread'] && $user->data['is_registered'] && isset($row['forum_mark_time'])) ? $row['forum_mark_time'] : 0; + $topic_forum_list[$row['forum_id']]['topics'][] = (int) $t_id; + } + + $topic_tracking_info = $tracking_topics = array(); if ($config['load_db_lastread']) { - $topic_tracking_info = get_topic_tracking(0, $topic_list, $rowset, false, $topic_list); + foreach ($topic_forum_list as $f_id => $topic_row) + { + $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time'])); + } } else { - $topic_tracking_info = get_complete_topic_tracking(0, $topic_list, $topic_list); + foreach ($topic_forum_list as $f_id => $topic_row) + { + $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics']); + } } + unset($topic_forum_list); foreach ($topic_list as $topic_id) { @@ -737,14 +760,14 @@ class ucp_main { foreach ($topic_forum_list as $f_id => $topic_row) { - $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time']), ($f_id == 0) ? $global_announce_list : false); + $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time'])); } } else { foreach ($topic_forum_list as $f_id => $topic_row) { - $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics'], $global_announce_list); + $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics']); } } diff --git a/phpBB/search.php b/phpBB/search.php index c68931f33f..4b1527b7e7 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -719,11 +719,11 @@ if ($keywords || $author || $author_id || $search_id || $submit) { if ($user->data['is_registered'] && $config['load_db_lastread']) { - $topic_tracking_info[$forum_id] = get_topic_tracking($forum_id, $forum['topic_list'], $forum['rowset'], array($forum_id => $forum['mark_time']), ($forum_id) ? false : $forum['topic_list']); + $topic_tracking_info[$forum_id] = get_topic_tracking($forum_id, $forum['topic_list'], $forum['rowset'], array($forum_id => $forum['mark_time'])); } else if ($config['load_anon_lastread'] || $user->data['is_registered']) { - $topic_tracking_info[$forum_id] = get_complete_topic_tracking($forum_id, $forum['topic_list'], ($forum_id) ? false : $forum['topic_list']); + $topic_tracking_info[$forum_id] = get_complete_topic_tracking($forum_id, $forum['topic_list']); if (!$user->data['is_registered']) { diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index fbc4d63405..0c673f1b74 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -324,7 +324,7 @@ $template->assign_vars(array( $icons = $cache->obtain_icons(); // Grab all topic data -$rowset = $announcement_list = $topic_list = $global_announce_list = array(); +$rowset = $announcement_list = $topic_list = $global_announce_forums = array(); $sql_array = array( 'SELECT' => 't.*', @@ -383,18 +383,40 @@ if ($forum_data['forum_type'] == FORUM_POST) $rowset[$row['topic_id']] = $row; $announcement_list[] = $row['topic_id']; - if ($row['topic_type'] == POST_GLOBAL) - { - $global_announce_list[$row['topic_id']] = true; - } - else + if ($forum_id == $row['forum_id']) { $topics_count--; } + else + { + $global_announce_forums[] = $row['forum_id']; + } } $db->sql_freeresult($result); } +$forum_tracking_info = array(); + +if ($user->data['is_registered']) +{ + $forum_tracking_info[$forum_id] = $forum_data['mark_time']; + + if (!empty($global_announce_forums) && $config['load_db_lastread']) + { + $sql = 'SELECT forum_id, mark_time + FROM ' . FORUMS_TRACK_TABLE . ' + WHERE ' . $db->sql_in_set('forum_id', $global_announce_forums) . ' + AND user_id = ' . $user->data['user_id']; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $forum_tracking_info[$row['forum_id']] = $row['mark_time']; + } + $db->sql_freeresult($result); + } +} + // If the user is trying to reach late pages, start searching from the end $store_reverse = false; $sql_limit = $config['topics_per_page']; @@ -552,45 +574,44 @@ if (sizeof($topic_list)) $mark_forum_read = true; $mark_time_forum = 0; - // Active topics? - if ($s_display_active && sizeof($active_forum_ary)) + // Generate topic forum list... + $topic_forum_list = array(); + foreach ($rowset as $t_id => $row) { - // Generate topic forum list... - $topic_forum_list = array(); - foreach ($rowset as $t_id => $row) + if (isset($forum_tracking_info[$row['forum_id']])) { - $topic_forum_list[$row['forum_id']]['forum_mark_time'] = ($config['load_db_lastread'] && $user->data['is_registered'] && isset($row['forum_mark_time'])) ? $row['forum_mark_time'] : 0; - $topic_forum_list[$row['forum_id']]['topics'][] = $t_id; + $row['forum_mark_time'] = $forum_tracking_info[$row['forum_id']]; } - if ($config['load_db_lastread'] && $user->data['is_registered']) - { - foreach ($topic_forum_list as $f_id => $topic_row) - { - $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time']), false); - } - } - else if ($config['load_anon_lastread'] || $user->data['is_registered']) - { - foreach ($topic_forum_list as $f_id => $topic_row) - { - $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics'], false); - } - } - - unset($topic_forum_list); + $topic_forum_list[$row['forum_id']]['forum_mark_time'] = ($config['load_db_lastread'] && $user->data['is_registered'] && isset($row['forum_mark_time'])) ? $row['forum_mark_time'] : 0; + $topic_forum_list[$row['forum_id']]['topics'][] = (int) $t_id; } - else + + if ($config['load_db_lastread'] && $user->data['is_registered']) + { + foreach ($topic_forum_list as $f_id => $topic_row) + { + $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time'])); + } + } + else if ($config['load_anon_lastread'] || $user->data['is_registered']) + { + foreach ($topic_forum_list as $f_id => $topic_row) + { + $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics']); + } + } + + unset($topic_forum_list); + + if (!$s_display_active) { if ($config['load_db_lastread'] && $user->data['is_registered']) { - $topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $rowset, array($forum_id => $forum_data['mark_time']), $global_announce_list); $mark_time_forum = (!empty($forum_data['mark_time'])) ? $forum_data['mark_time'] : $user->data['user_lastmark']; } else if ($config['load_anon_lastread'] || $user->data['is_registered']) { - $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list, $global_announce_list); - if (!$user->data['is_registered']) { $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0; From 0b85dded29b87feb09449d5a12388ccb23e9d1f2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 25 Mar 2010 12:31:37 +0100 Subject: [PATCH 138/170] [ticket/9684] View origin-forumname for GAs in topic-list Correct some links using ['forum_id'] instead of $forum_id. Correctly handle from "sort by day"-viewforum when there are global announcements displayed in the forum. PHPBB3-9684 --- .../prosilver/template/viewforum_body.html | 1 + phpBB/viewforum.php | 41 ++++++++++--------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/phpBB/styles/prosilver/template/viewforum_body.html b/phpBB/styles/prosilver/template/viewforum_body.html index ff1faa6734..b9e222bff1 100644 --- a/phpBB/styles/prosilver/template/viewforum_body.html +++ b/phpBB/styles/prosilver/template/viewforum_body.html @@ -144,6 +144,7 @@ {REPORTED_IMG}
{topicrow.PAGINATION} {topicrow.ATTACH_ICON_IMG} {L_POST_BY_AUTHOR} {topicrow.TOPIC_AUTHOR_FULL} » {topicrow.FIRST_POST_TIME} + » {L_IN} {topicrow.FORUM_NAME}
{topicrow.REPLIES} {L_REPLIES}
{topicrow.VIEWS} {L_VIEWS}
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 0c673f1b74..c53150d89b 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -177,8 +177,7 @@ if ($mark_read == 'topics') $token = request_var('hash', ''); if (check_link_hash($token, 'global')) { - // Add 0 to forums array to mark global announcements correctly - markread('topics', array($forum_id, 0)); + markread('topics', array($forum_id)); } $redirect_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id); meta_refresh(3, $redirect_url); @@ -238,9 +237,10 @@ if ($sort_days) $sql = 'SELECT COUNT(topic_id) AS num_topics FROM ' . TOPICS_TABLE . " WHERE forum_id = $forum_id - AND ((topic_type <> " . POST_GLOBAL . " AND topic_last_post_time >= $min_post_time) - OR topic_type = " . POST_ANNOUNCE . ") - " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND topic_approved = 1'); + AND (topic_last_post_time >= $min_post_time + OR topic_type = " . POST_ANNOUNCE . ' + OR topic_type = ' . POST_GLOBAL . ') + ' . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND topic_approved = 1'); $result = $db->sql_query($sql); $topics_count = (int) $db->sql_fetchfield('num_topics'); $db->sql_freeresult($result); @@ -363,11 +363,15 @@ if ($forum_data['forum_type'] == FORUM_POST) $g_forum_ary = $auth->acl_getf('f_read', true); $g_forum_ary = array_unique(array_keys($g_forum_ary)); + $sql_anounce_array['LEFT_JOIN'] = $sql_array['LEFT_JOIN']; + $sql_anounce_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = t.forum_id'); + $sql_anounce_array['SELECT'] = $sql_array['SELECT'] . ', f.forum_name'; + // Obtain announcements ... removed sort ordering, sort by time in all cases $sql = $db->sql_build_query('SELECT', array( - 'SELECT' => $sql_array['SELECT'], + 'SELECT' => $sql_anounce_array['SELECT'], 'FROM' => $sql_array['FROM'], - 'LEFT_JOIN' => $sql_array['LEFT_JOIN'], + 'LEFT_JOIN' => $sql_anounce_array['LEFT_JOIN'], 'WHERE' => '(t.forum_id = ' . $forum_id . ' AND t.topic_type = ' . POST_ANNOUNCE . ') OR @@ -383,12 +387,9 @@ if ($forum_data['forum_type'] == FORUM_POST) $rowset[$row['topic_id']] = $row; $announcement_list[] = $row['topic_id']; - if ($forum_id == $row['forum_id']) - { - $topics_count--; - } - else + if ($forum_id != $row['forum_id']) { + $topics_count++; $global_announce_forums[] = $row['forum_id']; } } @@ -649,16 +650,16 @@ if (sizeof($topic_list)) topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type); // Generate all the URIs ... - $view_topic_url_params = 'f=' . $topic_forum_id . '&t=' . $topic_id; + $view_topic_url_params = 'f=' . $row['forum_id'] . '&t=' . $topic_id; $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params); - $topic_unapproved = (!$row['topic_approved'] && $auth->acl_get('m_approve', $topic_forum_id)) ? true : false; - $posts_unapproved = ($row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $topic_forum_id)) ? true : false; + $topic_unapproved = (!$row['topic_approved'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false; + $posts_unapproved = ($row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false; $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&t=$topic_id", true, $user->session_id) : ''; // Send vars to template $template->assign_block_vars('topicrow', array( - 'FORUM_ID' => $topic_forum_id, + 'FORUM_ID' => $row['forum_id'], 'TOPIC_ID' => $topic_id, 'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), @@ -676,6 +677,7 @@ if (sizeof($topic_list)) 'VIEWS' => $row['topic_views'], 'TOPIC_TITLE' => censor_text($row['topic_title']), 'TOPIC_TYPE' => $topic_type, + 'FORUM_NAME' => (isset($row['forum_name'])) ? $row['forum_name'] : $forum_data['forum_name'], 'TOPIC_IMG_STYLE' => $folder_img, 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), @@ -687,13 +689,13 @@ if (sizeof($topic_list)) 'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '', 'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '', 'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '', - 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $topic_forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', + 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', 'UNAPPROVED_IMG' => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', 'S_TOPIC_TYPE' => $row['topic_type'], 'S_USER_POSTED' => (isset($row['topic_posted']) && $row['topic_posted']) ? true : false, 'S_UNREAD_TOPIC' => $unread_topic, - 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $topic_forum_id)) ? true : false, + 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $row['forum_id'])) ? true : false, 'S_TOPIC_UNAPPROVED' => $topic_unapproved, 'S_POSTS_UNAPPROVED' => $posts_unapproved, 'S_HAS_POLL' => ($row['poll_start']) ? true : false, @@ -708,7 +710,8 @@ if (sizeof($topic_list)) 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'U_VIEW_TOPIC' => $view_topic_url, - 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=reports&f=' . $topic_forum_id . '&t=' . $topic_id, true, $user->session_id), + 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']), + 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=reports&f=' . $row['forum_id'] . '&t=' . $topic_id, true, $user->session_id), 'U_MCP_QUEUE' => $u_mcp_queue, 'S_TOPIC_TYPE_SWITCH' => ($s_type_switch == $s_type_switch_test) ? -1 : $s_type_switch_test) From a9ad99302a723cd00725f57b27e9d85303d48e5a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 26 Jun 2010 00:51:13 +0200 Subject: [PATCH 139/170] [ticket/9684] Move currently existing GAs to a selectable forum while updating. PHPBB3-9684 --- phpBB/install/database_update.php | 140 ++++++++++++++++++++++++++++++ phpBB/language/en/install.php | 1 + 2 files changed, 141 insertions(+) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index cf611ca951..0d3e96f342 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -177,6 +177,69 @@ $database_update_info = database_update_info(); $error_ary = array(); $errored = false; +$sql = 'SELECT topic_id + FROM ' . TOPICS_TABLE . ' + WHERE forum_id = 0 + AND topic_type = ' . POST_GLOBAL; +$result = $db->sql_query_limit($sql, 1); +$has_global = (int) $db->sql_fetchfield('topic_id'); +$db->sql_freeresult($result); +$ga_forum_id = request_var('ga_forum_id', 0); + +if ($has_global && !$ga_forum_id) +{ + ?> + + + + + + + + + + <?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?> + + + + + + +
+ + +
+
+
+ +
+
+ +

+ +
+ +
+ + + + +
+ @@ -1962,6 +2025,83 @@ function change_database_data(&$no_updates, $version) _add_modules($modules_to_install); + // Localise Global Announcements + $sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour + FROM ' . TOPICS_TABLE . ' + WHERE forum_id = 0 + AND topic_type = ' . POST_GLOBAL; + $result = $db->sql_query($sql); + + $global_announcements = $update_lastpost_data = array(); + $update_lastpost_data['forum_last_post_time'] = 0; + $update_forum_data = array( + 'forum_posts' => 0, + 'forum_topics' => 0, + 'forum_topics_real' => 0, + ); + + while ($row = $db->sql_fetchrow($result)) + { + $global_announcements[] = (int) $row['topic_id']; + + $update_forum_data['forum_posts'] += (int) $row['topic_posts']; + $update_forum_data['forum_topics_real']++; + if ($row['topic_approved']) + { + $update_forum_data['forum_topics']++; + } + + if ($update_lastpost_data['forum_last_post_time'] < $row['topic_last_post_time']) + { + $update_lastpost_data = array( + 'forum_last_post_id' => (int) $row['topic_last_post_id'], + 'forum_last_post_subject' => $row['topic_last_post_subject'], + 'forum_last_post_time' => (int) $row['topic_last_post_time'], + 'forum_last_poster_id' => (int) $row['topic_last_poster_id'], + 'forum_last_poster_name' => $row['topic_last_poster_name'], + 'forum_last_poster_colour' => $row['topic_last_poster_colour'], + ); + } + } + $db->sql_freeresult($result); + + if (!empty($global_announcements)) + { + // Update the post/topic-count for the forum and the last-post if needed + $ga_forum_id = request_var('ga_forum_id', 0); + + $sql = 'SELECT forum_last_post_time + FROM ' . FORUMS_TABLE . ' + WHERE forum_id = ' . $ga_forum_id; + $result = $db->sql_query($sql); + $lastpost = (int) $db->sql_fetchfield('forum_last_post_time'); + $db->sql_freeresult($result); + + $sql_update = 'forum_posts = forum_posts + ' . $update_forum_data['forum_posts'] . ', '; + $sql_update .= 'forum_topics_real = forum_topics_real + ' . $update_forum_data['forum_topics_real'] . ', '; + $sql_update .= 'forum_topics = forum_topics + ' . $update_forum_data['forum_topics']; + if ($lastpost < $update_lastpost_data['forum_last_post_time']) + { + $sql_update .= ', ' . $db->sql_build_array('UPDATE', $update_lastpost_data); + } + + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET ' . $sql_update . ' + WHERE forum_id = ' . $ga_forum_id; + _sql($sql, $errored, $error_ary); + + // Update some forum_ids + $table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE); + foreach ($table_ary as $table) + { + $sql = "UPDATE $table + SET forum_id = $ga_forum_id + WHERE " . $db->sql_in_set('topic_id', $global_announcements); + _sql($sql, $errored, $error_ary); + } + unset($table_ary); + } + $no_updates = false; break; } diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php index 021f5eccb0..35fe28d8b5 100644 --- a/phpBB/language/en/install.php +++ b/phpBB/language/en/install.php @@ -323,6 +323,7 @@ $lang = array_merge($lang, array( 'SERVER_CONFIG' => 'Server configuration', 'SEARCH_INDEX_UNCONVERTED' => 'Search index was not converted', 'SEARCH_INDEX_UNCONVERTED_EXPLAIN' => 'Your old search index was not converted. Searching will always yield an empty result. To create a new search index go to the Administration Control Panel, select Maintenance and then choose Search index from the submenu.', + 'SELECT_FORUM_GA' => 'In phpBB 3.1 the global announcements are linked to forums. Select a forum for your current global announcements (can be moved later):', 'SOFTWARE' => 'Board software', 'SPECIFY_OPTIONS' => 'Specify conversion options', 'STAGE_ADMINISTRATOR' => 'Administrator details', From ad81637300bfbbb4f18d80cd87326fbc90dd38f8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 3 Feb 2011 15:00:48 +0100 Subject: [PATCH 140/170] [ticket/9684] Also display forum-name in subsilver2 template PHPBB3-9684 --- phpBB/styles/subsilver2/template/search_results.html | 8 ++------ phpBB/styles/subsilver2/template/viewforum_body.html | 1 + 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/phpBB/styles/subsilver2/template/search_results.html b/phpBB/styles/subsilver2/template/search_results.html index 823d057f06..282b0f864b 100644 --- a/phpBB/styles/subsilver2/template/search_results.html +++ b/phpBB/styles/subsilver2/template/search_results.html @@ -45,11 +45,7 @@

[ {GOTO_PAGE_IMG}{L_GOTO_PAGE}: {searchresults.PAGINATION} ]

- -

{L_GLOBAL}

- -

{L_IN} {searchresults.FORUM_TITLE}

- +

{L_IN} {searchresults.FORUM_TITLE}

{searchresults.TOPIC_AUTHOR_FULL}

{searchresults.TOPIC_REPLIES}

@@ -84,7 +80,7 @@ {searchresults.L_IGNORE_POST} -

 {L_FORUM}: {searchresults.FORUM_TITLE}{L_GLOBAL}   {L_TOPIC}: {searchresults.TOPIC_TITLE}

+

 {L_FORUM}: {searchresults.FORUM_TITLE}   {L_TOPIC}: {searchresults.TOPIC_TITLE}

diff --git a/phpBB/styles/subsilver2/template/viewforum_body.html b/phpBB/styles/subsilver2/template/viewforum_body.html index 65d8ef51c0..5c20b84541 100644 --- a/phpBB/styles/subsilver2/template/viewforum_body.html +++ b/phpBB/styles/subsilver2/template/viewforum_body.html @@ -202,6 +202,7 @@

[ {GOTO_PAGE_IMG}{L_GOTO_PAGE}: {topicrow.PAGINATION} ]

+

{L_IN} {topicrow.FORUM_NAME}

{topicrow.TOPIC_AUTHOR_FULL}

{topicrow.REPLIES}

From a72fe8acafa85b5a65a40c7661487d8cee7776f5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 7 Apr 2011 14:53:47 +0200 Subject: [PATCH 141/170] [ticket/10109] Fix "Undefined Index" errors when copying a topic. PHPBB3-10109 --- phpBB/includes/mcp/mcp_main.php | 61 +++++++++++++++++---------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index d5551f5114..ad10a52705 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -1048,37 +1048,38 @@ function mcp_fork_topic($topic_ids) $total_posts = 0; $new_topic_id_list = array(); - if ($topic_data['enable_indexing']) - { - // Select the search method and do some additional checks to ensure it can actually be utilised - $search_type = basename($config['search_type']); - - if (!file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx)) - { - trigger_error('NO_SUCH_SEARCH_MODULE'); - } - - if (!class_exists($search_type)) - { - include("{$phpbb_root_path}includes/search/$search_type.$phpEx"); - } - - $error = false; - $search = new $search_type($error); - $search_mode = 'post'; - - if ($error) - { - trigger_error($error); - } - } - else - { - $search_type = false; - } foreach ($topic_data as $topic_id => $topic_row) { + if (!isset($search_type) && $topic_row['enable_indexing']) + { + // Select the search method and do some additional checks to ensure it can actually be utilised + $search_type = basename($config['search_type']); + + if (!file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx)) + { + trigger_error('NO_SUCH_SEARCH_MODULE'); + } + + if (!class_exists($search_type)) + { + include("{$phpbb_root_path}includes/search/$search_type.$phpEx"); + } + + $error = false; + $search = new $search_type($error); + $search_mode = 'post'; + + if ($error) + { + trigger_error($error); + } + } + else if (!isset($search_type) && !$topic_row['enable_indexing']) + { + $search_type = false; + } + $sql_ary = array( 'forum_id' => (int) $to_forum_id, 'icon_id' => (int) $topic_row['icon_id'], @@ -1187,9 +1188,9 @@ function mcp_fork_topic($topic_ids) // Copy whether the topic is dotted markread('post', $to_forum_id, $new_topic_id, 0, $row['poster_id']); - if ($search_type) + if (!empty($search_type)) { - $search->index($search_mode, $sql_ary['post_id'], $sql_ary['post_text'], $sql_ary['post_subject'], $sql_ary['poster_id'], ($topic_row['topic_type'] == POST_GLOBAL) ? 0 : $to_forum_id); + $search->index($search_mode, $new_post_id, $sql_ary['post_text'], $sql_ary['post_subject'], $sql_ary['poster_id'], ($topic_row['topic_type'] == POST_GLOBAL) ? 0 : $to_forum_id); $search_mode = 'reply'; // After one we index replies } From 851bb9fcd869b71140f75ed3a454ade2447c1328 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 7 Apr 2011 20:36:11 +0200 Subject: [PATCH 142/170] [ticket/10084] Add smilie/icon errors out when file is missing PHPBB3-10084 --- phpBB/includes/acp/acp_icons.php | 4 ++++ phpBB/language/en/acp/posting.php | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index 3d64a2acda..24f6cbbcbf 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -394,6 +394,10 @@ class acp_icons { // skip images where add wasn't checked } + else if (!file_exists($phpbb_root_path . $img_path . '/' . $image)) + { + $errors[$image] = 'SMILIE_NO_FILE'; + } else { if ($image_width[$image] == 0 || $image_height[$image] == 0) diff --git a/phpBB/language/en/acp/posting.php b/phpBB/language/en/acp/posting.php index 25152dd766..0fad400ea9 100644 --- a/phpBB/language/en/acp/posting.php +++ b/phpBB/language/en/acp/posting.php @@ -168,8 +168,9 @@ $lang = array_merge($lang, array( 'SMILIES_CONFIG' => 'Smiley configuration', 'SMILIES_DELETED' => 'The smiley has been removed successfully.', 'SMILIES_EDIT' => 'Edit smiley', - 'SMILIE_NO_CODE' => 'The smilie “%s” was ignored, as there was no code entered.', + 'SMILIE_NO_CODE' => 'The smilie “%s” was ignored, as there was no code entered.', 'SMILIE_NO_EMOTION' => 'The smilie “%s” was ignored, as there was no emotion entered.', + 'SMILIE_NO_FILE' => 'The smilie “%s” was ignored, as the file is missing.', 'SMILIES_NONE_EDITED' => 'No smilies were updated.', 'SMILIES_ONE_EDITED' => 'The smiley has been updated successfully.', 'SMILIES_EDITED' => 'The smilies have been updated successfully.', From 5798c8f02e7ac7dd73dbbd7953467926b369023e Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 8 Apr 2011 12:30:43 +0200 Subject: [PATCH 143/170] [ticket/10123] Change "smilie" to "smiley" as per our coding guidelines. PHPBB3-10123 --- phpBB/language/en/acp/posting.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/language/en/acp/posting.php b/phpBB/language/en/acp/posting.php index 0fad400ea9..9719287c2a 100644 --- a/phpBB/language/en/acp/posting.php +++ b/phpBB/language/en/acp/posting.php @@ -168,9 +168,9 @@ $lang = array_merge($lang, array( 'SMILIES_CONFIG' => 'Smiley configuration', 'SMILIES_DELETED' => 'The smiley has been removed successfully.', 'SMILIES_EDIT' => 'Edit smiley', - 'SMILIE_NO_CODE' => 'The smilie “%s” was ignored, as there was no code entered.', - 'SMILIE_NO_EMOTION' => 'The smilie “%s” was ignored, as there was no emotion entered.', - 'SMILIE_NO_FILE' => 'The smilie “%s” was ignored, as the file is missing.', + 'SMILIE_NO_CODE' => 'The smiley “%s” was ignored, as there was no code entered.', + 'SMILIE_NO_EMOTION' => 'The smiley “%s” was ignored, as there was no emotion entered.', + 'SMILIE_NO_FILE' => 'The smiley “%s” was ignored, as the file is missing.', 'SMILIES_NONE_EDITED' => 'No smilies were updated.', 'SMILIES_ONE_EDITED' => 'The smiley has been updated successfully.', 'SMILIES_EDITED' => 'The smilies have been updated successfully.', From 97864d69ee66134f04936137e2357caf99cd9f30 Mon Sep 17 00:00:00 2001 From: rxu Date: Thu, 17 Feb 2011 23:31:05 +0700 Subject: [PATCH 144/170] [feature/attachment-management-no-reassignment] Attachments management This feature allows to manage attachments in posts and PMs via ACP. PHPBB3-9721 --- phpBB/adm/style/acp_attachments.html | 68 +++++++++ phpBB/includes/acp/acp_attachments.php | 154 ++++++++++++++++++++ phpBB/includes/acp/info/acp_attachments.php | 1 + phpBB/language/en/acp/common.php | 7 + 4 files changed, 230 insertions(+) diff --git a/phpBB/adm/style/acp_attachments.html b/phpBB/adm/style/acp_attachments.html index 22f271ea82..c11d3c7117 100644 --- a/phpBB/adm/style/acp_attachments.html +++ b/phpBB/adm/style/acp_attachments.html @@ -371,6 +371,74 @@ + + +
+ +
+ {L_TITLE} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{L_FILENAME}{L_FILEDATE}{L_FILESIZE}{L_ATTACH_POST_ID}{L_DELETE}
{attachments.REAL_FILENAME}
{attachments.L_DOWNLOAD_COUNT}
{L_IN} {L_PRIVATE_MESSAGE}{L_TOPIC}: {attachments.TOPIC_TITLE}
{attachments.FILETIME}
{L_POST_BY_AUTHOR} {attachments.ATTACHMENT_POSTER}
{attachments.FILESIZE} + + + +
 {L_MARK_ALL} :: {L_UNMARK_ALL}
+ +
+ {L_DISPLAY_LOG}:  {S_LIMIT_DAYS} {L_SORT_BY}: {S_SORT_KEY} {S_SORT_DIR} + + {S_FORM_TOKEN} +
+
+ + + + + +
+ +

+   + +

+ +
+ +
+ diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php index 3179be7de7..7d796adf03 100644 --- a/phpBB/includes/acp/acp_attachments.php +++ b/phpBB/includes/acp/acp_attachments.php @@ -61,6 +61,10 @@ class acp_attachments $l_title = 'ACP_ORPHAN_ATTACHMENTS'; break; + case 'attachments': + $l_title = 'ACP_MANAGE_ATTACHMENTS'; + break; + default: trigger_error('NO_MODE', E_USER_ERROR); break; @@ -1043,6 +1047,156 @@ class acp_attachments $db->sql_freeresult($result); break; + + case 'attachments': + + if ($submit) + { + $delete_files = (isset($_POST['delete'])) ? array_keys(request_var('delete', array('' => 0))) : array(); + + if (sizeof($delete_files)) + { + // Select those attachments we want to delete... + $sql = 'SELECT real_filename + FROM ' . ATTACHMENTS_TABLE . ' + WHERE ' . $db->sql_in_set('attach_id', $delete_files) . ' + AND is_orphan = 0'; + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + $deleted_filenames[] = $row['real_filename']; + } + $db->sql_freeresult($result); + delete_attachments('attach', $delete_files); + add_log('admin', 'LOG_ATTACHMENTS_DELETED', implode(', ', $deleted_filenames)); + $notify[] = sprintf($user->lang['LOG_ATTACHMENTS_DELETED'], implode(', ', $deleted_filenames)); + } + } + + $template->assign_vars(array( + 'S_ATTACHMENTS' => true) + ); + + // Sort keys + $sort_days = request_var('st', 0); + $sort_key = request_var('sk', 't'); + $sort_dir = request_var('sd', 'd'); + + // Sorting + $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); + $sort_by_text = array('f' => $user->lang['FILENAME'], 't' => $user->lang['FILEDATE'], 's' => $user->lang['FILESIZE'], 'x' => $user->lang['EXTENSION'], 'd' => $user->lang['DOWNLOADS'],'p' => $user->lang['ATTACH_POST_ID'], 'u' => $user->lang['AUTHOR']); + $sort_by_sql = array('f' => 'a.real_filename', 't' => 'a.filetime', 's' => 'a.filesize', 'x' => 'a.extension', 'd' => 'a.download_count', 'p' => 'a.post_msg_id', 'u' => 'u.username'); + + $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; + gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); + + $min_filetime = ($sort_days) ? (time() - ($sort_days * 86400)) : ''; + $limit_filetime = ($min_filetime) ? " AND a.filetime >= $min_filetime " : ''; + $start = ($sort_days && isset($_POST['sort'])) ? 0 : $start; + + $num_files = (int) $config['num_files']; + $total_size = get_formatted_filesize((int) $config['upload_dir_size']); + + // Make sure $start is set to the last page if it exceeds the amount + if ($start < 0 || $start > $num_files) + { + $start = ($start < 0) ? 0 : floor(($num_files - 1) / $config['posts_per_page']) * $config['posts_per_page']; + } + + // If the user is trying to reach the second half of the attachments list, fetch it starting from the end + $store_reverse = false; + $sql_limit = $config['posts_per_page']; + + if ($start > $num_files / 2) + { + $store_reverse = true; + + if ($start + $config['posts_per_page'] > $num_files) + { + $sql_limit = min($config['posts_per_page'], max(1, $num_files - $start)); + } + + // Select the sort order. Add time sort anchor for non-time sorting cases + $sql_sort_anchor = ($sort_key != 't') ? ', a.filetime ' . (($sort_dir == 'd') ? 'ASC' : 'DESC') : ''; + $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'ASC' : 'DESC') . $sql_sort_anchor; + $sql_start = max(0, $num_files - $sql_limit - $start); + } + else + { + // Select the sort order. Add time sort anchor for non-time sorting cases + $sql_sort_anchor = ($sort_key != 't') ? ', a.filetime ' . (($sort_dir == 'd') ? 'DESC' : 'ASC') : ''; + $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC') . $sql_sort_anchor; + $sql_start = $start; + + } + + $attachments_list = array(); + + // Just get the files + $sql = 'SELECT a.*, u.username, u.user_colour, t.topic_title + FROM ' . ATTACHMENTS_TABLE . ' a + LEFT JOIN ' . USERS_TABLE . ' u ON (u.user_id = a.poster_id) + LEFT JOIN ' . TOPICS_TABLE . " t ON (a.topic_id = t.topic_id) + WHERE a.is_orphan = 0 + $limit_filetime + ORDER BY $sql_sort_order"; + $result = $db->sql_query_limit($sql, $sql_limit, $sql_start); + + $i = ($store_reverse) ? $sql_limit - 1 : 0; + while ($attachment_row = $db->sql_fetchrow($result)) + { + $attachments_list[$i] = $attachment_row; + ($store_reverse) ? $i-- : $i++; + } + $db->sql_freeresult($result); + + $template->assign_vars(array( + 'TOTAL_FILES' => $num_files, + 'TOTAL_SIZE' => $total_size, + 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param", $num_files, $config['posts_per_page'], $start, true), + + 'S_ON_PAGE' => on_page($num_files, $config['posts_per_page'], $start), + 'S_LIMIT_DAYS' => $s_limit_days, + 'S_SORT_KEY' => $s_sort_key, + 'S_SORT_DIR' => $s_sort_dir) + ); + + // Grab extensions + $extensions = array(); + $extensions = $cache->obtain_attach_extensions(true); + + for ($i = 0, $end = sizeof($attachments_list); $i < $end; ++$i) + { + $row =& $attachments_list[$i]; + + $row['extension'] = strtolower(trim((string) $row['extension'])); + $display_cat = $extensions[$row['extension']]['display_cat']; + $l_downloaded_viewed = ($display_cat == ATTACHMENT_CATEGORY_NONE) ? 'DOWNLOAD_COUNT' : 'VIEWED_COUNT'; + $l_download_count = (!isset($row['download_count']) || (int) $row['download_count'] == 0) ? $user->lang[$l_downloaded_viewed . '_NONE'] : (((int) $row['download_count'] == 1) ? sprintf($user->lang[$l_downloaded_viewed], $row['download_count']) : sprintf($user->lang[$l_downloaded_viewed . 'S'], $row['download_count'])); + + $template->assign_block_vars('attachments', array( + 'ATTACHMENT_POSTER' => get_username_string('full', (int) $row['poster_id'], (string) $row['username'], (string) $row['user_colour'], (string) $row['username']), + 'FILESIZE' => get_formatted_filesize((int) $row['filesize']), + 'FILETIME' => $user->format_date((int) $row['filetime']), + 'REAL_FILENAME' => utf8_wordwrap(utf8_basename((string) $row['real_filename']), 40, '
', true), + 'PHYSICAL_FILENAME' => utf8_basename((string) $row['physical_filename']), + 'TOPIC_TITLE' => (!$row['in_message']) ? (string) $row['topic_title'] : '', + 'DISABLED' => 'disabled="disabled"', + 'ATTACH_ID' => (int) $row['attach_id'], + 'POST_ID' => (int) $row['post_msg_id'], + 'TOPIC_ID' => (int) $row['topic_id'], + 'POST_IDS' => (!empty($post_ids[$row['attach_id']])) ? (int) $post_ids[$row['attach_id']] : '', + + 'L_DOWNLOAD_COUNT' => $l_download_count, + + 'S_IN_MESSAGE' => (bool) $row['in_message'], + + 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row['topic_id']}&p={$row['post_msg_id']}") . "#p{$row['post_msg_id']}", + 'U_FILE' => append_sid($phpbb_root_path . 'download/file.' . $phpEx, 'mode=view&id=' . $row['attach_id'])) + ); + } + + break; } if (sizeof($error)) diff --git a/phpBB/includes/acp/info/acp_attachments.php b/phpBB/includes/acp/info/acp_attachments.php index d5f57ece4e..945392bc2a 100644 --- a/phpBB/includes/acp/info/acp_attachments.php +++ b/phpBB/includes/acp/info/acp_attachments.php @@ -24,6 +24,7 @@ class acp_attachments_info 'extensions' => array('title' => 'ACP_MANAGE_EXTENSIONS', 'auth' => 'acl_a_attach', 'cat' => array('ACP_ATTACHMENTS')), 'ext_groups' => array('title' => 'ACP_EXTENSION_GROUPS', 'auth' => 'acl_a_attach', 'cat' => array('ACP_ATTACHMENTS')), 'orphan' => array('title' => 'ACP_ORPHAN_ATTACHMENTS', 'auth' => 'acl_a_attach', 'cat' => array('ACP_ATTACHMENTS')) + 'attachments' => array('title' => 'ACP_MANAGE_ATTACHMENTS', 'auth' => 'acl_a_attach', 'cat' => array('ACP_ATTACHMENTS')), ), ); } diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 847e763ae8..9f89b6284c 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -116,6 +116,10 @@ $lang = array_merge($lang, array( 'ACP_LOGGING' => 'Logging', 'ACP_MAIN' => 'ACP index', + + 'ACP_MANAGE_ATTACHMENTS' => 'Manage attachments', + 'ACP_MANAGE_ATTACHMENTS_EXPLAIN' => 'Here you can manage files attached to posts. You are able to delete the files or reassign them to existing posts. Reassigning to posts requires a valid post ID, you have to determine this ID by yourself. This will reassign the already assigned attachment to the post you entered.', + 'ACP_MANAGE_EXTENSIONS' => 'Manage extensions', 'ACP_MANAGE_FORUMS' => 'Manage forums', 'ACP_MANAGE_RANKS' => 'Manage ranks', @@ -227,6 +231,7 @@ $lang = array_merge($lang, array( 'DOWNLOAD_AS' => 'Download as', 'DOWNLOAD_STORE' => 'Download or store file', 'DOWNLOAD_STORE_EXPLAIN' => 'You may directly download the file or save it in your store/ folder.', + 'DOWNLOADS' => 'Downloads', 'EDIT' => 'Edit', 'ENABLE' => 'Enable', @@ -284,6 +289,8 @@ $lang = array_merge($lang, array( 'SHOW_ALL_OPERATIONS' => 'Show all operations', + 'TOTAL_SIZE' => 'Total size', + 'UCP' => 'User Control Panel', 'USERNAMES_EXPLAIN' => 'Place each username on a separate line.', 'USER_CONTROL_PANEL' => 'User Control Panel', From 804a11074bfb6c8e1fef6f39d1b720468ff56a2f Mon Sep 17 00:00:00 2001 From: rxu Date: Mon, 14 Mar 2011 00:03:31 +0700 Subject: [PATCH 145/170] [feature/attachment-management-no-reassignment] Fix minor flaws in the code. Thanks to Oleg for inspection. PHPBB3-9721 --- phpBB/includes/acp/acp_attachments.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php index 7d796adf03..b926f0c771 100644 --- a/phpBB/includes/acp/acp_attachments.php +++ b/phpBB/includes/acp/acp_attachments.php @@ -1137,9 +1137,9 @@ class acp_attachments FROM ' . ATTACHMENTS_TABLE . ' a LEFT JOIN ' . USERS_TABLE . ' u ON (u.user_id = a.poster_id) LEFT JOIN ' . TOPICS_TABLE . " t ON (a.topic_id = t.topic_id) - WHERE a.is_orphan = 0 - $limit_filetime - ORDER BY $sql_sort_order"; + WHERE a.is_orphan = 0 + $limit_filetime + ORDER BY $sql_sort_order"; $result = $db->sql_query_limit($sql, $sql_limit, $sql_start); $i = ($store_reverse) ? $sql_limit - 1 : 0; @@ -1161,8 +1161,7 @@ class acp_attachments 'S_SORT_DIR' => $s_sort_dir) ); - // Grab extensions - $extensions = array(); + // Grab extensions information $extensions = $cache->obtain_attach_extensions(true); for ($i = 0, $end = sizeof($attachments_list); $i < $end; ++$i) From 259929ad4e7e0c527f652e3bff1db48e7533fd08 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 11 Apr 2011 00:29:48 +0200 Subject: [PATCH 146/170] [ticket/10128] Pass E_USER_WARNING to trigger_error() calls from user_ban(). The user_ban() function is shared by the MCP and the ACP. Mark trigger_error() calls as errors by passing E_USER_WARNING to make the error message appear on red background (instead of green background) in the ACP. PHPBB3-10128 --- phpBB/includes/functions_user.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 89ce52dc39..6b5cca8abb 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -733,7 +733,7 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas } else { - trigger_error('LENGTH_BAN_INVALID'); + trigger_error('LENGTH_BAN_INVALID', E_USER_WARNING); } } } @@ -793,7 +793,7 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas // Make sure we have been given someone to ban if (!sizeof($sql_usernames)) { - trigger_error('NO_USER_SPECIFIED'); + trigger_error('NO_USER_SPECIFIED', E_USER_WARNING); } $sql = 'SELECT user_id @@ -824,7 +824,7 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas else { $db->sql_freeresult($result); - trigger_error('NO_USERS'); + trigger_error('NO_USERS', E_USER_WARNING); } $db->sql_freeresult($result); break; @@ -926,7 +926,7 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas if (empty($banlist_ary)) { - trigger_error('NO_IPS_DEFINED'); + trigger_error('NO_IPS_DEFINED', E_USER_WARNING); } } break; @@ -954,12 +954,12 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas if (sizeof($ban_list) == 0) { - trigger_error('NO_EMAILS_DEFINED'); + trigger_error('NO_EMAILS_DEFINED', E_USER_WARNING); } break; default: - trigger_error('NO_MODE'); + trigger_error('NO_MODE', E_USER_WARNING); break; } From 6bb55e80a4070fa82c09f2b7442cde3391a5c184 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sun, 10 Apr 2011 23:50:24 -0400 Subject: [PATCH 147/170] [ticket/10136] Added missing $request globalizations in functions.php. PHPBB3-10136 --- phpBB/includes/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index f910611b76..52e3aafe15 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1380,7 +1380,7 @@ function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time, $ */ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_list = false) { - global $config, $user; + global $config, $user, $request; $last_read = array(); @@ -1644,7 +1644,7 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s */ function update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_time = false, $mark_time_forum = false) { - global $db, $tracking_topics, $user, $config; + global $db, $tracking_topics, $user, $config, $request; // Determine the users last forum mark time if not given. if ($mark_time_forum === false) From d3523f4f8718c98d5c5709e1c05c6ab7c28f04aa Mon Sep 17 00:00:00 2001 From: rxu Date: Mon, 11 Apr 2011 12:32:31 +0800 Subject: [PATCH 148/170] [feature/attachment-management-no-reassignment] Fix some more errors Missing comma for orphan key in info module, define $start variable PHPBB3-9721 --- phpBB/includes/acp/acp_attachments.php | 2 ++ phpBB/includes/acp/info/acp_attachments.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php index b926f0c771..7cc84b5a8e 100644 --- a/phpBB/includes/acp/acp_attachments.php +++ b/phpBB/includes/acp/acp_attachments.php @@ -1076,6 +1076,8 @@ class acp_attachments $template->assign_vars(array( 'S_ATTACHMENTS' => true) ); + + $start = request_var('start', 0); // Sort keys $sort_days = request_var('st', 0); diff --git a/phpBB/includes/acp/info/acp_attachments.php b/phpBB/includes/acp/info/acp_attachments.php index 945392bc2a..d55003bbe5 100644 --- a/phpBB/includes/acp/info/acp_attachments.php +++ b/phpBB/includes/acp/info/acp_attachments.php @@ -23,7 +23,7 @@ class acp_attachments_info 'attach' => array('title' => 'ACP_ATTACHMENT_SETTINGS', 'auth' => 'acl_a_attach', 'cat' => array('ACP_BOARD_CONFIGURATION', 'ACP_ATTACHMENTS')), 'extensions' => array('title' => 'ACP_MANAGE_EXTENSIONS', 'auth' => 'acl_a_attach', 'cat' => array('ACP_ATTACHMENTS')), 'ext_groups' => array('title' => 'ACP_EXTENSION_GROUPS', 'auth' => 'acl_a_attach', 'cat' => array('ACP_ATTACHMENTS')), - 'orphan' => array('title' => 'ACP_ORPHAN_ATTACHMENTS', 'auth' => 'acl_a_attach', 'cat' => array('ACP_ATTACHMENTS')) + 'orphan' => array('title' => 'ACP_ORPHAN_ATTACHMENTS', 'auth' => 'acl_a_attach', 'cat' => array('ACP_ATTACHMENTS')), 'attachments' => array('title' => 'ACP_MANAGE_ATTACHMENTS', 'auth' => 'acl_a_attach', 'cat' => array('ACP_ATTACHMENTS')), ), ); From d811820bc11bac61076d5a92d741d22df9944af8 Mon Sep 17 00:00:00 2001 From: rxu Date: Mon, 11 Apr 2011 19:59:50 +0800 Subject: [PATCH 149/170] [feature/attachment-management-no-reassignment] Further feature adjustments. -add database update entry; - add files statistics checks; - improve files deletion procedure; - improve reversed order for pagination; - adjust template file; - add missing comma for orphan key in info module; - change module mode name; - fix module explanation text; - add files comments output; - change attachments per page amount from posts to topics per page value. PHPBB3-9721 --- phpBB/adm/style/acp_attachments.html | 19 ++---- phpBB/includes/acp/acp_attachments.php | 75 +++++++++++++++------ phpBB/includes/acp/info/acp_attachments.php | 2 +- phpBB/install/database_update.php | 7 ++ phpBB/language/en/acp/common.php | 6 +- 5 files changed, 75 insertions(+), 34 deletions(-) diff --git a/phpBB/adm/style/acp_attachments.html b/phpBB/adm/style/acp_attachments.html index c11d3c7117..4a75a9b63b 100644 --- a/phpBB/adm/style/acp_attachments.html +++ b/phpBB/adm/style/acp_attachments.html @@ -371,7 +371,7 @@ - +
@@ -388,41 +388,34 @@ {L_FILENAME} - {L_FILEDATE} + {L_POSTED} {L_FILESIZE} - {L_ATTACH_POST_ID} {L_DELETE} - {attachments.REAL_FILENAME}
{attachments.L_DOWNLOAD_COUNT}
{L_IN} {L_PRIVATE_MESSAGE}{L_TOPIC}: {attachments.TOPIC_TITLE} + {attachments.REAL_FILENAME}
{attachments.COMMENT}
{attachments.L_DOWNLOAD_COUNT}
{L_IN} {L_PRIVATE_MESSAGE}{L_TOPIC}: {attachments.TOPIC_TITLE} {attachments.FILETIME}
{L_POST_BY_AUTHOR} {attachments.ATTACHMENT_POSTER} {attachments.FILESIZE} - - - - - -   +   {L_MARK_ALL} :: {L_UNMARK_ALL} +
{L_DISPLAY_LOG}:  {S_LIMIT_DAYS} {L_SORT_BY}: {S_SORT_KEY} {S_SORT_DIR} - {S_FORM_TOKEN}

- @@ -434,7 +427,7 @@  

- + {S_FORM_TOKEN}
diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php index 7cc84b5a8e..1c3c43c8e9 100644 --- a/phpBB/includes/acp/acp_attachments.php +++ b/phpBB/includes/acp/acp_attachments.php @@ -61,7 +61,7 @@ class acp_attachments $l_title = 'ACP_ORPHAN_ATTACHMENTS'; break; - case 'attachments': + case 'manage': $l_title = 'ACP_MANAGE_ATTACHMENTS'; break; @@ -1048,7 +1048,7 @@ class acp_attachments break; - case 'attachments': + case 'manage': if ($submit) { @@ -1067,16 +1067,27 @@ class acp_attachments $deleted_filenames[] = $row['real_filename']; } $db->sql_freeresult($result); - delete_attachments('attach', $delete_files); - add_log('admin', 'LOG_ATTACHMENTS_DELETED', implode(', ', $deleted_filenames)); - $notify[] = sprintf($user->lang['LOG_ATTACHMENTS_DELETED'], implode(', ', $deleted_filenames)); + + if ($num_deleted = delete_attachments('attach', $delete_files)) + { + if (sizeof($delete_files) != $num_deleted) + { + $error[] = $user->lang['FILES_GONE']; + } + add_log('admin', 'LOG_ATTACHMENTS_DELETED', implode(', ', $deleted_filenames)); + $notify[] = sprintf($user->lang['LOG_ATTACHMENTS_DELETED'], implode(', ', $deleted_filenames)); + } + else + { + $error[] = $user->lang['NO_FILES_TO_DELETE']; + } } } $template->assign_vars(array( - 'S_ATTACHMENTS' => true) + 'S_MANAGE' => true) ); - + $start = request_var('start', 0); // Sort keys @@ -1096,26 +1107,48 @@ class acp_attachments $limit_filetime = ($min_filetime) ? " AND a.filetime >= $min_filetime " : ''; $start = ($sort_days && isset($_POST['sort'])) ? 0 : $start; + $attachments_per_page = (int) $config['topics_per_page']; + $num_files = (int) $config['num_files']; - $total_size = get_formatted_filesize((int) $config['upload_dir_size']); + $total_size = (int) $config['upload_dir_size']; + + // Check if files statistics is accurate + $sql = 'SELECT COUNT(attach_id) as num_files + FROM ' . ATTACHMENTS_TABLE . ' + WHERE is_orphan = 0'; + $result = $db->sql_query($sql, 600); + $num_files_real = (int) $db->sql_fetchfield('num_files'); + $db->sql_freeresult($result); + + $sql = 'SELECT SUM(filesize) as upload_dir_size + FROM ' . ATTACHMENTS_TABLE . ' + WHERE is_orphan = 0'; + $result = $db->sql_query($sql, 600); + $total_size_real = (int) $db->sql_fetchfield('upload_dir_size'); + $db->sql_freeresult($result); + + if (($num_files != $num_files_real) || ($total_size != $total_size_real)) + { + $error[] = sprintf($user->lang['FILES_STAT_WRONG'], $num_files_real, get_formatted_filesize($total_size_real)); + } // Make sure $start is set to the last page if it exceeds the amount if ($start < 0 || $start > $num_files) { - $start = ($start < 0) ? 0 : floor(($num_files - 1) / $config['posts_per_page']) * $config['posts_per_page']; + $start = ($start < 0) ? 0 : floor(($num_files - 1) / $attachments_per_page) * $attachments_per_page; } // If the user is trying to reach the second half of the attachments list, fetch it starting from the end $store_reverse = false; - $sql_limit = $config['posts_per_page']; + $sql_limit = $attachments_per_page; if ($start > $num_files / 2) { $store_reverse = true; - if ($start + $config['posts_per_page'] > $num_files) + if ($start + $attachments_per_page > $num_files) { - $sql_limit = min($config['posts_per_page'], max(1, $num_files - $start)); + $sql_limit = min($attachments_per_page, max(1, $num_files - $start)); } // Select the sort order. Add time sort anchor for non-time sorting cases @@ -1145,32 +1178,36 @@ class acp_attachments $result = $db->sql_query_limit($sql, $sql_limit, $sql_start); $i = ($store_reverse) ? $sql_limit - 1 : 0; + + // Store increment value in a variable to save some conditional calls + $i_increment = ($store_reverse) ? -1 : 1; while ($attachment_row = $db->sql_fetchrow($result)) { $attachments_list[$i] = $attachment_row; - ($store_reverse) ? $i-- : $i++; + $i = $i + $i_increment; } $db->sql_freeresult($result); $template->assign_vars(array( 'TOTAL_FILES' => $num_files, - 'TOTAL_SIZE' => $total_size, - 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param", $num_files, $config['posts_per_page'], $start, true), + 'TOTAL_SIZE' => get_formatted_filesize($total_size), + 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param", $num_files, $attachments_per_page, $start, true), - 'S_ON_PAGE' => on_page($num_files, $config['posts_per_page'], $start), + 'S_ON_PAGE' => on_page($num_files, $attachments_per_page, $start), 'S_LIMIT_DAYS' => $s_limit_days, 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir) ); - // Grab extensions information + // Grab extensions $extensions = $cache->obtain_attach_extensions(true); for ($i = 0, $end = sizeof($attachments_list); $i < $end; ++$i) { - $row =& $attachments_list[$i]; + $row = $attachments_list[$i]; $row['extension'] = strtolower(trim((string) $row['extension'])); + $comment = ($row['attach_comment']) ? str_replace(array("\n", "\r"), array('
', "\n"), $row['attach_comment']) : ''; $display_cat = $extensions[$row['extension']]['display_cat']; $l_downloaded_viewed = ($display_cat == ATTACHMENT_CATEGORY_NONE) ? 'DOWNLOAD_COUNT' : 'VIEWED_COUNT'; $l_download_count = (!isset($row['download_count']) || (int) $row['download_count'] == 0) ? $user->lang[$l_downloaded_viewed . '_NONE'] : (((int) $row['download_count'] == 1) ? sprintf($user->lang[$l_downloaded_viewed], $row['download_count']) : sprintf($user->lang[$l_downloaded_viewed . 'S'], $row['download_count'])); @@ -1181,8 +1218,8 @@ class acp_attachments 'FILETIME' => $user->format_date((int) $row['filetime']), 'REAL_FILENAME' => utf8_wordwrap(utf8_basename((string) $row['real_filename']), 40, '
', true), 'PHYSICAL_FILENAME' => utf8_basename((string) $row['physical_filename']), + 'COMMENT' => $comment, 'TOPIC_TITLE' => (!$row['in_message']) ? (string) $row['topic_title'] : '', - 'DISABLED' => 'disabled="disabled"', 'ATTACH_ID' => (int) $row['attach_id'], 'POST_ID' => (int) $row['post_msg_id'], 'TOPIC_ID' => (int) $row['topic_id'], diff --git a/phpBB/includes/acp/info/acp_attachments.php b/phpBB/includes/acp/info/acp_attachments.php index d55003bbe5..4bcd7e2ea5 100644 --- a/phpBB/includes/acp/info/acp_attachments.php +++ b/phpBB/includes/acp/info/acp_attachments.php @@ -24,7 +24,7 @@ class acp_attachments_info 'extensions' => array('title' => 'ACP_MANAGE_EXTENSIONS', 'auth' => 'acl_a_attach', 'cat' => array('ACP_ATTACHMENTS')), 'ext_groups' => array('title' => 'ACP_EXTENSION_GROUPS', 'auth' => 'acl_a_attach', 'cat' => array('ACP_ATTACHMENTS')), 'orphan' => array('title' => 'ACP_ORPHAN_ATTACHMENTS', 'auth' => 'acl_a_attach', 'cat' => array('ACP_ATTACHMENTS')), - 'attachments' => array('title' => 'ACP_MANAGE_ATTACHMENTS', 'auth' => 'acl_a_attach', 'cat' => array('ACP_ATTACHMENTS')), + 'manage' => array('title' => 'ACP_MANAGE_ATTACHMENTS', 'auth' => 'acl_a_attach', 'cat' => array('ACP_ATTACHMENTS')), ), ); } diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index cf611ca951..4f2a5966ee 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1958,6 +1958,13 @@ function change_database_data(&$no_updates, $version) 'auth' => 'acl_a_group', 'cat' => 'ACP_GROUPS', ), + 'manage' => array( + 'base' => 'attachments', + 'class' => 'acp', + 'title' => 'ACP_MANAGE_ATTACHMENTS', + 'auth' => 'acl_a_attach', + 'cat' => 'ACP_ATTACHMENTS', + ), ); _add_modules($modules_to_install); diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 9f89b6284c..11e8e05a56 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -118,7 +118,7 @@ $lang = array_merge($lang, array( 'ACP_MAIN' => 'ACP index', 'ACP_MANAGE_ATTACHMENTS' => 'Manage attachments', - 'ACP_MANAGE_ATTACHMENTS_EXPLAIN' => 'Here you can manage files attached to posts. You are able to delete the files or reassign them to existing posts. Reassigning to posts requires a valid post ID, you have to determine this ID by yourself. This will reassign the already assigned attachment to the post you entered.', + 'ACP_MANAGE_ATTACHMENTS_EXPLAIN' => 'Here you can list and delete files attached to posts and private messages.', 'ACP_MANAGE_EXTENSIONS' => 'Manage extensions', 'ACP_MANAGE_FORUMS' => 'Manage forums', @@ -238,6 +238,9 @@ $lang = array_merge($lang, array( 'EXPORT_DOWNLOAD' => 'Download', 'EXPORT_STORE' => 'Store', + 'FILES_GONE' => 'Some of the attachments you selected for deletion do not exist. They may have been already deleted. Attachments that did exist were deleted.', + 'FILES_STAT_WRONG' => 'Your files statistics is probably inaccurate and might need to be resynchronised. Actual values: number of attachments » %1$d, total size of attachments » %2$s.', + 'GENERAL_OPTIONS' => 'General options', 'GENERAL_SETTINGS' => 'General settings', 'GLOBAL_MASK' => 'Global permission mask', @@ -263,6 +266,7 @@ $lang = array_merge($lang, array( 'NOTIFY' => 'Notification', 'NO_ADMIN' => 'You are not authorised to administer this board.', 'NO_EMAILS_DEFINED' => 'No valid e-mail addresses found.', + 'NO_FILES_TO_DELETE' => 'Attachments you selected for deletion do not exist.', 'NO_PASSWORD_SUPPLIED' => 'You need to enter your password to access the Administration Control Panel.', 'OFF' => 'Off', From 9a8a8d41d3db957a14ab8d07143157ef8d36391d Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sun, 17 Apr 2011 18:41:18 -0400 Subject: [PATCH 150/170] [ticket/7252] Removed an outdated comment pertaining to PHP 4.x. PHPBB3-7252 --- phpBB/includes/functions_posting.php | 1 - 1 file changed, 1 deletion(-) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 3f6dbfa41f..0bb0ef8722 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -560,7 +560,6 @@ function get_supported_image_types($type = false) if ($type !== false) { // Type is one of the IMAGETYPE constants - it is fetched from getimagesize() - // We do not use the constants here, because some were not available in PHP 4.3.x switch ($type) { // GIF From 682814180c647c363c83ef09c66b2b97bda1eac4 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sun, 17 Apr 2011 18:46:03 -0400 Subject: [PATCH 151/170] [ticket/7941] Added @return to generate_board_url docstring. PHPBB3-7941 --- phpBB/includes/functions.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 585e23b2ee..b8ea80ad4a 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2253,7 +2253,10 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false) /** * Generate board url (example: http://www.example.com/phpBB) +* * @param bool $without_script_path if set to true the script path gets not appended (example: http://www.example.com) +* +* @return string the generated board url */ function generate_board_url($without_script_path = false) { From 2f67ade05a426d41c95c146a86251d388c718b61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=A8rejean?= Date: Mon, 24 Jan 2011 15:13:15 +0100 Subject: [PATCH 152/170] [ticket/10006] Add phpbb_config::delete Add the missing `phpbb_config::delete` method to the config class PHPBB3-10006 --- phpBB/includes/config/config.php | 20 ++++++++++++++++++++ phpBB/includes/config/db.php | 32 ++++++++++++++++++++++++++++++++ tests/config/config_test.php | 9 +++++++++ tests/config/db_test.php | 7 +++++++ 4 files changed, 68 insertions(+) diff --git a/phpBB/includes/config/config.php b/phpBB/includes/config/config.php index 64fef28cfa..9596b1e15b 100644 --- a/phpBB/includes/config/config.php +++ b/phpBB/includes/config/config.php @@ -103,6 +103,26 @@ class phpbb_config implements ArrayAccess, IteratorAggregate, Countable return count($this->config); } + /** + * Removes a configuration option + * + * @param String $key The configuration option's name + * @param bool $cache Whether this variable should be cached or if it + * changes too frequently to be efficiently cached + * @return bool True if the configuration entry was deleted successfully, + * otherwise false + */ + public function delete($key, $cache = true) + { + if (!isset($this->config[$key])) + { + return false; + } + + unset($this->config[$key]); + return true; + } + /** * Sets a configuration option's value * diff --git a/phpBB/includes/config/db.php b/phpBB/includes/config/db.php index 74fb0504ce..f0c9a5d591 100644 --- a/phpBB/includes/config/db.php +++ b/phpBB/includes/config/db.php @@ -90,6 +90,38 @@ class phpbb_config_db extends phpbb_config parent::__construct($config); } + /** + * Removes a configuration option + * + * @param String $key The configuration option's name + * @param bool $cache Whether this variable should be cached or if it + * changes too frequently to be efficiently cached + * @return bool True if the configuration entry was deleted successfully, + * otherwise false + */ + public function delete($key, $cache = true) + { + if (!isset($this->config[$key])) + { + return false; + } + + $sql = 'DELETE FROM ' . $this->table . " + WHERE config_name = '" . $this->db->sql_escape($key) . "'"; + $this->db->sql_query($sql); + if (!$this->db->sql_affectedrows()) + { + return false; + } + + unset($this->config[$key]); + + if ($cache) + { + $this->cache->destroy('config'); + } + } + /** * Sets a configuration option's value * diff --git a/tests/config/config_test.php b/tests/config/config_test.php index 73a365c847..e4444eccda 100644 --- a/tests/config/config_test.php +++ b/tests/config/config_test.php @@ -109,4 +109,13 @@ class phpbb_config_test extends phpbb_test_case $config->increment('foo', 1); $this->assertEquals(27, $config['foo']); } + + public function test_delete() + { + $config = new phpbb_config(array('foo' => 'bar')); + + $this->assertTrue(isset($config['foo'])); + $config->delete('foo'); + $this->assertFalse(isset($config['foo'])); + } } diff --git a/tests/config/db_test.php b/tests/config/db_test.php index e0d5252f19..d37b31dbbd 100644 --- a/tests/config/db_test.php +++ b/tests/config/db_test.php @@ -125,4 +125,11 @@ class phpbb_config_db_test extends phpbb_database_test_case $this->config->increment('foobar', 3); $this->assertEquals(3, $this->config['foobar']);; } + + public function test_delete() + { + $this->assertTrue(isset($this->config['foo'])); + $this->config->delete('foo', false); + $this->assertFalse(isset($this->config['foo'])); + } } From 7b1638c37f9de64a0f6f7c712a063c7ef0d6d4aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=A8rejean?= Date: Mon, 24 Jan 2011 15:22:46 +0100 Subject: [PATCH 153/170] [ticket/10006] Tweak the tests a bit PHPBB3-10006 --- tests/config/config_test.php | 1 - tests/config/db_test.php | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/config/config_test.php b/tests/config/config_test.php index e4444eccda..9c91d9eb87 100644 --- a/tests/config/config_test.php +++ b/tests/config/config_test.php @@ -114,7 +114,6 @@ class phpbb_config_test extends phpbb_test_case { $config = new phpbb_config(array('foo' => 'bar')); - $this->assertTrue(isset($config['foo'])); $config->delete('foo'); $this->assertFalse(isset($config['foo'])); } diff --git a/tests/config/db_test.php b/tests/config/db_test.php index d37b31dbbd..aa3d40999a 100644 --- a/tests/config/db_test.php +++ b/tests/config/db_test.php @@ -129,7 +129,11 @@ class phpbb_config_db_test extends phpbb_database_test_case public function test_delete() { $this->assertTrue(isset($this->config['foo'])); - $this->config->delete('foo', false); + $this->config->delete('foo'); $this->assertFalse(isset($this->config['foo'])); + + // re-read config and populate cache + $config2 = new phpbb_config_db($this->db, $this->cache, 'phpbb_config'); + $this->cache->checkVarUnset($this, 'foo'); } } From 503b87da481d5a77091b519144e8b862b4569f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=A8rejean?= Date: Mon, 24 Jan 2011 16:33:42 +0100 Subject: [PATCH 154/170] [ticket/10006] More testing Change the DB test to test agains new cache/config mock objects PHPBB3-10006 --- tests/config/db_test.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/config/db_test.php b/tests/config/db_test.php index aa3d40999a..5bd5296e5a 100644 --- a/tests/config/db_test.php +++ b/tests/config/db_test.php @@ -130,10 +130,13 @@ class phpbb_config_db_test extends phpbb_database_test_case { $this->assertTrue(isset($this->config['foo'])); $this->config->delete('foo'); + $this->cache->checkVarUnset($this, 'foo'); $this->assertFalse(isset($this->config['foo'])); // re-read config and populate cache - $config2 = new phpbb_config_db($this->db, $this->cache, 'phpbb_config'); - $this->cache->checkVarUnset($this, 'foo'); + $cache2 = new phpbb_mock_cache; + $config2 = new phpbb_config_db($this->db, $cache2, 'phpbb_config'); + $cache2->checkVarUnset($this, 'foo'); + $this->assertFalse(isset($config2['foo'])); } } From f93ac340a298dae9f45d99ea2b418532942bd423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=A8rejean?= Date: Mon, 24 Jan 2011 16:43:09 +0100 Subject: [PATCH 155/170] [ticket/10006] Remove return values Remove some unneeded return values PHPBB3-10006 --- phpBB/includes/config/config.php | 6 ++---- phpBB/includes/config/db.php | 9 ++------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/phpBB/includes/config/config.php b/phpBB/includes/config/config.php index 9596b1e15b..ff352abe84 100644 --- a/phpBB/includes/config/config.php +++ b/phpBB/includes/config/config.php @@ -109,18 +109,16 @@ class phpbb_config implements ArrayAccess, IteratorAggregate, Countable * @param String $key The configuration option's name * @param bool $cache Whether this variable should be cached or if it * changes too frequently to be efficiently cached - * @return bool True if the configuration entry was deleted successfully, - * otherwise false + * @return void */ public function delete($key, $cache = true) { if (!isset($this->config[$key])) { - return false; + return; } unset($this->config[$key]); - return true; } /** diff --git a/phpBB/includes/config/db.php b/phpBB/includes/config/db.php index f0c9a5d591..caa2cff7f1 100644 --- a/phpBB/includes/config/db.php +++ b/phpBB/includes/config/db.php @@ -96,23 +96,18 @@ class phpbb_config_db extends phpbb_config * @param String $key The configuration option's name * @param bool $cache Whether this variable should be cached or if it * changes too frequently to be efficiently cached - * @return bool True if the configuration entry was deleted successfully, - * otherwise false + * @return void */ public function delete($key, $cache = true) { if (!isset($this->config[$key])) { - return false; + return; } $sql = 'DELETE FROM ' . $this->table . " WHERE config_name = '" . $this->db->sql_escape($key) . "'"; $this->db->sql_query($sql); - if (!$this->db->sql_affectedrows()) - { - return false; - } unset($this->config[$key]); From 27bbfde2437302ec0b7848513eb15cb91c8e07ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=A8rejean?= Date: Mon, 24 Jan 2011 22:35:42 +0100 Subject: [PATCH 156/170] [ticket/10006] Remove unneeded if statements Remove some of the additional `if (isset)` checks PHPBB3-10006 --- phpBB/includes/config/config.php | 5 ----- phpBB/includes/config/db.php | 5 ----- 2 files changed, 10 deletions(-) diff --git a/phpBB/includes/config/config.php b/phpBB/includes/config/config.php index ff352abe84..4ba05a98ec 100644 --- a/phpBB/includes/config/config.php +++ b/phpBB/includes/config/config.php @@ -113,11 +113,6 @@ class phpbb_config implements ArrayAccess, IteratorAggregate, Countable */ public function delete($key, $cache = true) { - if (!isset($this->config[$key])) - { - return; - } - unset($this->config[$key]); } diff --git a/phpBB/includes/config/db.php b/phpBB/includes/config/db.php index caa2cff7f1..f98056e013 100644 --- a/phpBB/includes/config/db.php +++ b/phpBB/includes/config/db.php @@ -100,11 +100,6 @@ class phpbb_config_db extends phpbb_config */ public function delete($key, $cache = true) { - if (!isset($this->config[$key])) - { - return; - } - $sql = 'DELETE FROM ' . $this->table . " WHERE config_name = '" . $this->db->sql_escape($key) . "'"; $this->db->sql_query($sql); From 9241aa79ff8ab8a940cee01a301162187c24d198 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 19 Apr 2011 10:13:18 +0200 Subject: [PATCH 157/170] [ticket/10139] Rename $cache to $use_cache to avoid confusion with cache object PHPBB3-10139 --- phpBB/includes/config/config.php | 26 +++++++++++----------- phpBB/includes/config/db.php | 38 ++++++++++++++++---------------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/phpBB/includes/config/config.php b/phpBB/includes/config/config.php index 4ba05a98ec..a273391dc8 100644 --- a/phpBB/includes/config/config.php +++ b/phpBB/includes/config/config.php @@ -106,12 +106,12 @@ class phpbb_config implements ArrayAccess, IteratorAggregate, Countable /** * Removes a configuration option * - * @param String $key The configuration option's name - * @param bool $cache Whether this variable should be cached or if it - * changes too frequently to be efficiently cached + * @param String $key The configuration option's name + * @param bool $use_cache Whether this variable should be cached or if it + * changes too frequently to be efficiently cached * @return void */ - public function delete($key, $cache = true) + public function delete($key, $use_cache = true) { unset($this->config[$key]); } @@ -119,12 +119,12 @@ class phpbb_config implements ArrayAccess, IteratorAggregate, Countable /** * Sets a configuration option's value * - * @param string $key The configuration option's name - * @param string $value New configuration value - * @param bool $cache Whether this variable should be cached or if it - * changes too frequently to be efficiently cached. + * @param string $key The configuration option's name + * @param string $value New configuration value + * @param bool $use_cache Whether this variable should be cached or if it + * changes too frequently to be efficiently cached. */ - public function set($key, $value, $cache = true) + public function set($key, $value, $use_cache = true) { $this->config[$key] = $value; } @@ -136,11 +136,11 @@ class phpbb_config implements ArrayAccess, IteratorAggregate, Countable * @param string $key The configuration option's name * @param string $old_value Current configuration value * @param string $value New configuration value - * @param bool $cache Whether this variable should be cached or if it + * @param bool $use_cache Whether this variable should be cached or if it * changes too frequently to be efficiently cached. * @return bool True if the value was changed, false otherwise. */ - public function set_atomic($key, $old_value, $value, $cache = true) + public function set_atomic($key, $old_value, $value, $use_cache = true) { if (!isset($this->config[$key]) || $this->config[$key] == $old_value) { @@ -155,10 +155,10 @@ class phpbb_config implements ArrayAccess, IteratorAggregate, Countable * * @param string $key The configuration option's name * @param int $increment Amount to increment by - * @param bool $cache Whether this variable should be cached or if it + * @param bool $use_cache Whether this variable should be cached or if it * changes too frequently to be efficiently cached. */ - function increment($key, $increment, $cache = true) + function increment($key, $increment, $use_cache = true) { if (!isset($this->config[$key])) { diff --git a/phpBB/includes/config/db.php b/phpBB/includes/config/db.php index f98056e013..a2db4056df 100644 --- a/phpBB/includes/config/db.php +++ b/phpBB/includes/config/db.php @@ -93,12 +93,12 @@ class phpbb_config_db extends phpbb_config /** * Removes a configuration option * - * @param String $key The configuration option's name - * @param bool $cache Whether this variable should be cached or if it - * changes too frequently to be efficiently cached + * @param String $key The configuration option's name + * @param bool $use_cache Whether this variable should be cached or if it + * changes too frequently to be efficiently cached * @return void */ - public function delete($key, $cache = true) + public function delete($key, $use_cache = true) { $sql = 'DELETE FROM ' . $this->table . " WHERE config_name = '" . $this->db->sql_escape($key) . "'"; @@ -106,7 +106,7 @@ class phpbb_config_db extends phpbb_config unset($this->config[$key]); - if ($cache) + if ($use_cache) { $this->cache->destroy('config'); } @@ -115,14 +115,14 @@ class phpbb_config_db extends phpbb_config /** * Sets a configuration option's value * - * @param string $key The configuration option's name - * @param string $value New configuration value - * @param bool $cache Whether this variable should be cached or if it - * changes too frequently to be efficiently cached. + * @param string $key The configuration option's name + * @param string $value New configuration value + * @param bool $use_cache Whether this variable should be cached or if it + * changes too frequently to be efficiently cached. */ - public function set($key, $value, $cache = true) + public function set($key, $value, $use_cache = true) { - $this->set_atomic($key, false, $value, $cache); + $this->set_atomic($key, false, $value, $use_cache); } /** @@ -133,11 +133,11 @@ class phpbb_config_db extends phpbb_config * @param mixed $old_value Current configuration value or false to ignore * the old value * @param string $new_value New configuration value - * @param bool $cache Whether this variable should be cached or if it + * @param bool $use_cache Whether this variable should be cached or if it * changes too frequently to be efficiently cached * @return bool True if the value was changed, false otherwise */ - public function set_atomic($key, $old_value, $new_value, $cache = true) + public function set_atomic($key, $old_value, $new_value, $use_cache = true) { $sql = 'UPDATE ' . $this->table . " SET config_value = '" . $this->db->sql_escape($new_value) . "' @@ -160,11 +160,11 @@ class phpbb_config_db extends phpbb_config $sql = 'INSERT INTO ' . $this->table . ' ' . $this->db->sql_build_array('INSERT', array( 'config_name' => $key, 'config_value' => $new_value, - 'is_dynamic' => ($cache) ? 0 : 1)); + 'is_dynamic' => ($use_cache) ? 0 : 1)); $this->db->sql_query($sql); } - if ($cache) + if ($use_cache) { $this->cache->destroy('config'); } @@ -181,14 +181,14 @@ class phpbb_config_db extends phpbb_config * * @param string $key The configuration option's name * @param int $increment Amount to increment by - * @param bool $cache Whether this variable should be cached or if it + * @param bool $use_cache Whether this variable should be cached or if it * changes too frequently to be efficiently cached. */ - function increment($key, $increment, $cache = true) + function increment($key, $increment, $use_cache = true) { if (!isset($this->config[$key])) { - $this->set($key, '0', $cache); + $this->set($key, '0', $use_cache); } $sql_update = $this->db->cast_expr_to_string($this->db->cast_expr_to_bigint('config_value') . ' + ' . (int) $increment); @@ -197,7 +197,7 @@ class phpbb_config_db extends phpbb_config SET config_value = ' . $sql_update . " WHERE config_name = '" . $this->db->sql_escape($key) . "'"); - if ($cache) + if ($use_cache) { $this->cache->destroy('config'); } From 2701a587acba06ea503ca6463d42471687ff597a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 19 Apr 2011 10:17:18 +0200 Subject: [PATCH 158/170] [ticket/10139] Make signatures of set_atomic() consistent by using $new_value. PHPBB3-10139 --- phpBB/includes/config/config.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/config/config.php b/phpBB/includes/config/config.php index a273391dc8..354dc85c03 100644 --- a/phpBB/includes/config/config.php +++ b/phpBB/includes/config/config.php @@ -135,16 +135,16 @@ class phpbb_config implements ArrayAccess, IteratorAggregate, Countable * * @param string $key The configuration option's name * @param string $old_value Current configuration value - * @param string $value New configuration value + * @param string $new_value New configuration value * @param bool $use_cache Whether this variable should be cached or if it * changes too frequently to be efficiently cached. * @return bool True if the value was changed, false otherwise. */ - public function set_atomic($key, $old_value, $value, $use_cache = true) + public function set_atomic($key, $old_value, $new_value, $use_cache = true) { if (!isset($this->config[$key]) || $this->config[$key] == $old_value) { - $this->config[$key] = $value; + $this->config[$key] = $new_value; return true; } return false; From 1d2201902f0f3789daf02ca054f33f4b4bfa3eb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=A8rejean?= Date: Thu, 30 Dec 2010 16:03:11 +0100 Subject: [PATCH 159/170] [ticket/9961] Create log entries when users are activated. * Create log entries when a user activates own account without also changing their password. * Additionally create admin log entries when an administrator activates user accounts. PHPBB3-9961 --- phpBB/includes/ucp/ucp_activate.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/phpBB/includes/ucp/ucp_activate.php b/phpBB/includes/ucp/ucp_activate.php index 8debaabf31..b00c1b9f52 100644 --- a/phpBB/includes/ucp/ucp_activate.php +++ b/phpBB/includes/ucp/ucp_activate.php @@ -98,6 +98,13 @@ class ucp_activate SET user_actkey = '' WHERE user_id = {$user_row['user_id']}"; $db->sql_query($sql); + + // Create the correct logs + add_log('user', $user_row['user_id'], 'LOG_USER_ACTIVE_USER'); + if ($auth->acl_get('a_user')) + { + add_log('admin', 'LOG_USER_ACTIVE', $user_row['username']); + } } if ($config['require_activation'] == USER_ACTIVATION_ADMIN && !$update_password) From 11dd4b54fa1f3a15448271061e51907e3ba5c79d Mon Sep 17 00:00:00 2001 From: Bart van Bragt Date: Thu, 21 Apr 2011 04:21:09 -0400 Subject: [PATCH 160/170] [ticket/10141] Use a cache in $auth->_fill_acl() for better performance. Many sequences being converted are the same. Use a local cache to convert each sequence once, speeding up the function. PHPBB3-10141 --- phpBB/includes/auth.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/auth.php b/phpBB/includes/auth.php index 02819f9e78..22fafd7b7f 100644 --- a/phpBB/includes/auth.php +++ b/phpBB/includes/auth.php @@ -109,6 +109,7 @@ class auth */ function _fill_acl($user_permissions) { + $seq_cache = array(); $this->acl = array(); $user_permissions = explode("\n", $user_permissions); @@ -125,8 +126,15 @@ class auth while ($subseq = substr($seq, $i, 6)) { - // We put the original bitstring into the acl array - $this->acl[$f] .= str_pad(base_convert($subseq, 36, 2), 31, 0, STR_PAD_LEFT); + if (isset($seq_cache[$subseq])) + { + $this->acl[$f] .= $seq_cache[$subseq]; + } + else + { + // We put the original bitstring into the acl array + $this->acl[$f] .= ($seq_cache[$subseq] = str_pad(base_convert($subseq, 36, 2), 31, 0, STR_PAD_LEFT)); + } $i += 6; } } From b1367bce488d0acea00a5ebf8725d0cde5515655 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 22 Apr 2011 00:15:05 +0200 Subject: [PATCH 161/170] [ticket/10141] Split double-assignment into conditional and unconditional part. PHPBB3-10141 --- phpBB/includes/auth.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/phpBB/includes/auth.php b/phpBB/includes/auth.php index 22fafd7b7f..4b13c6be7f 100644 --- a/phpBB/includes/auth.php +++ b/phpBB/includes/auth.php @@ -126,15 +126,13 @@ class auth while ($subseq = substr($seq, $i, 6)) { - if (isset($seq_cache[$subseq])) + if (!isset($seq_cache[$subseq])) { - $this->acl[$f] .= $seq_cache[$subseq]; - } - else - { - // We put the original bitstring into the acl array - $this->acl[$f] .= ($seq_cache[$subseq] = str_pad(base_convert($subseq, 36, 2), 31, 0, STR_PAD_LEFT)); + $seq_cache[$subseq] = str_pad(base_convert($subseq, 36, 2), 31, 0, STR_PAD_LEFT); } + + // We put the original bitstring into the acl array + $this->acl[$f] .= $seq_cache[$subseq]; $i += 6; } } From 6ee6245e5b283a0868ed219b145af94a5be090a7 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 22 Apr 2011 00:30:13 +0200 Subject: [PATCH 162/170] [ticket/10137] Remove unintended space at end of PHP_URL_FOPEN_SUPPORT_EXPLAIN. PHPBB3-10137 --- phpBB/language/en/install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php index 11c5d78359..37147cc6a0 100644 --- a/phpBB/language/en/install.php +++ b/phpBB/language/en/install.php @@ -302,7 +302,7 @@ $lang = array_merge($lang, array( 'PHP_SETTINGS' => 'PHP version and settings', 'PHP_SETTINGS_EXPLAIN' => 'Required - You must be running at least version 4.3.3 of PHP in order to install phpBB. If safe mode is displayed below your PHP installation is running in that mode. This will impose limitations on remote administration and similar features.', 'PHP_URL_FOPEN_SUPPORT' => 'PHP setting allow_url_fopen is enabled', - 'PHP_URL_FOPEN_SUPPORT_EXPLAIN' => 'Optional - This setting is optional, however certain phpBB functions like off-site avatars will not work properly without it. ', + 'PHP_URL_FOPEN_SUPPORT_EXPLAIN' => 'Optional - This setting is optional, however certain phpBB functions like off-site avatars will not work properly without it.', 'PHP_VERSION_REQD' => 'PHP version >= 4.3.3', 'POST_ID' => 'Post ID', 'PREFIX_FOUND' => 'A scan of your tables has shown a valid installation using %s as table prefix.', From 78fa3a3b03df4739c80c7bcabab5b64c1b0476ce Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 22 Apr 2011 00:41:55 +0200 Subject: [PATCH 163/170] [ticket/10105] Update AIM application download link. PHPBB3-10105 --- phpBB/styles/prosilver/template/memberlist_im.html | 2 +- phpBB/styles/subsilver2/template/memberlist_im.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/styles/prosilver/template/memberlist_im.html b/phpBB/styles/prosilver/template/memberlist_im.html index acc7ec359b..bda235d477 100644 --- a/phpBB/styles/prosilver/template/memberlist_im.html +++ b/phpBB/styles/prosilver/template/memberlist_im.html @@ -39,7 +39,7 @@
 
{L_IM_ADD_CONTACT}
{L_IM_SEND_MESSAGE}
-
{L_IM_DOWNLOAD_APP} | {L_IM_AIM_EXPRESS}
+
{L_IM_DOWNLOAD_APP} | {L_IM_AIM_EXPRESS}
diff --git a/phpBB/styles/subsilver2/template/memberlist_im.html b/phpBB/styles/subsilver2/template/memberlist_im.html index e8d86128c7..f720a1ff86 100644 --- a/phpBB/styles/subsilver2/template/memberlist_im.html +++ b/phpBB/styles/subsilver2/template/memberlist_im.html @@ -19,7 +19,7 @@ -
{L_IM_ADD_CONTACT}
{L_IM_SEND_MESSAGE}

{L_IM_DOWNLOAD_APP} | {L_IM_AIM_EXPRESS} +
{L_IM_ADD_CONTACT}
{L_IM_SEND_MESSAGE}

{L_IM_DOWNLOAD_APP} | {L_IM_AIM_EXPRESS}   From 8c3cfbb40ea267f02eceef000a324116707530a3 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 22 Apr 2011 00:42:49 +0200 Subject: [PATCH 164/170] [ticket/10105] Update AIM express link. PHPBB3-10105 --- phpBB/styles/prosilver/template/memberlist_im.html | 2 +- phpBB/styles/subsilver2/template/memberlist_im.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/styles/prosilver/template/memberlist_im.html b/phpBB/styles/prosilver/template/memberlist_im.html index bda235d477..49de3b2596 100644 --- a/phpBB/styles/prosilver/template/memberlist_im.html +++ b/phpBB/styles/prosilver/template/memberlist_im.html @@ -39,7 +39,7 @@
 
{L_IM_ADD_CONTACT}
{L_IM_SEND_MESSAGE}
-
{L_IM_DOWNLOAD_APP} | {L_IM_AIM_EXPRESS}
+
{L_IM_DOWNLOAD_APP} | {L_IM_AIM_EXPRESS}
diff --git a/phpBB/styles/subsilver2/template/memberlist_im.html b/phpBB/styles/subsilver2/template/memberlist_im.html index f720a1ff86..0a92fd2ba0 100644 --- a/phpBB/styles/subsilver2/template/memberlist_im.html +++ b/phpBB/styles/subsilver2/template/memberlist_im.html @@ -19,7 +19,7 @@ -
{L_IM_ADD_CONTACT}
{L_IM_SEND_MESSAGE}

{L_IM_DOWNLOAD_APP} | {L_IM_AIM_EXPRESS} +
{L_IM_ADD_CONTACT}
{L_IM_SEND_MESSAGE}

{L_IM_DOWNLOAD_APP} | {L_IM_AIM_EXPRESS}   From 5e7c945de99b3c4201378164cded0df667793add Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 21 Apr 2011 23:00:25 -0400 Subject: [PATCH 165/170] [ticket/10143] Added tests for storing a previously deleted value in db cache. PHPBB3-10143 --- tests/config/db_test.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/config/db_test.php b/tests/config/db_test.php index 5bd5296e5a..e817545a54 100644 --- a/tests/config/db_test.php +++ b/tests/config/db_test.php @@ -139,4 +139,28 @@ class phpbb_config_db_test extends phpbb_database_test_case $cache2->checkVarUnset($this, 'foo'); $this->assertFalse(isset($config2['foo'])); } + + public function test_delete_write_read_not_cacheable() + { + // bar is dynamic + $this->assertTrue(isset($this->config['bar'])); + $this->config->delete('bar'); + $this->cache->checkVarUnset($this, 'bar'); + $this->assertFalse(isset($this->config['bar'])); + + $this->config->set('bar', 'new bar', false); + $this->assertEquals('new bar', $this->config['bar']); + } + + public function test_delete_write_read_cacheable() + { + // foo is not dynamic + $this->assertTrue(isset($this->config['foo'])); + $this->config->delete('foo'); + $this->cache->checkVarUnset($this, 'foo'); + $this->assertFalse(isset($this->config['foo'])); + + $this->config->set('foo', 'new foo', true); + $this->assertEquals('new foo', $this->config['foo']); + } } From f49656986cc1898e85d6d7e4cd859ec8e980dc4a Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 21 Apr 2011 23:15:51 -0400 Subject: [PATCH 166/170] [ticket/10141] Save a hash lookup when value is not in cache. PHPBB3-10141 --- phpBB/includes/auth.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/auth.php b/phpBB/includes/auth.php index 4b13c6be7f..8324cb4977 100644 --- a/phpBB/includes/auth.php +++ b/phpBB/includes/auth.php @@ -126,13 +126,17 @@ class auth while ($subseq = substr($seq, $i, 6)) { - if (!isset($seq_cache[$subseq])) + if (isset($seq_cache[$subseq])) { - $seq_cache[$subseq] = str_pad(base_convert($subseq, 36, 2), 31, 0, STR_PAD_LEFT); + $converted = $seq_cache[$subseq]; + } + else + { + $converted = $seq_cache[$subseq] = str_pad(base_convert($subseq, 36, 2), 31, 0, STR_PAD_LEFT); } // We put the original bitstring into the acl array - $this->acl[$f] .= $seq_cache[$subseq]; + $this->acl[$f] .= $converted; $i += 6; } } From a8ecd30fe1fbee46a7605c60c95b813fdf26719b Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 21 Apr 2011 12:00:04 -0400 Subject: [PATCH 167/170] [ticket/10147] Corrected a typo in includes/functions_template.php. PHPBB3-10147 --- phpBB/includes/functions_template.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions_template.php b/phpBB/includes/functions_template.php index 1d3a4d74f8..8636dfe010 100644 --- a/phpBB/includes/functions_template.php +++ b/phpBB/includes/functions_template.php @@ -322,7 +322,7 @@ class template_compile // Is the designer wanting to call another loop in a loop? if (strpos($tag_args, '!') === 0) { - // Count the number if ! occurrences (not allowed in vars) + // Count the number of ! occurrences (not allowed in vars) $no_nesting = substr_count($tag_args, '!'); $tag_args = substr($tag_args, $no_nesting); } From dfbbc4797ea9908db727e5fc51d06bd55cd0c472 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sun, 24 Apr 2011 01:35:09 -0400 Subject: [PATCH 168/170] [ticket/10148] Turn TEMPLATE_BITFIELD into an instance variable. PHPBB3-10148 --- phpBB/includes/acp/acp_styles.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 6a0d4c4c98..e32a4d2310 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -45,7 +45,7 @@ class acp_styles $bitfield->set(9); $bitfield->set(11); $bitfield->set(12); - define('TEMPLATE_BITFIELD', $bitfield->get_base64()); + $this->template_bitfield = $bitfield->get_base64(); unset($bitfield); $user->add_lang('acp/styles'); @@ -3496,7 +3496,7 @@ parse_css_file = {PARSE_CSS_FILE} } else { - $sql_ary['bbcode_bitfield'] = TEMPLATE_BITFIELD; + $sql_ary['bbcode_bitfield'] = $this->template_bitfield; } // We set a pre-defined bitfield here which we may use further in 3.2 From baba66a22991e93908a8b4e7f8bfa104b3588450 Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 24 Apr 2011 23:33:51 +0800 Subject: [PATCH 169/170] [feature/attachment-management-no-reassignment] Handle privacy and some more. - restrict files info for PM attachments; - add an option to resync files stats if wrong; - replace post_id sorting with post type (PM/regular post) one; - some language fixes. PHPBB3-9721 --- phpBB/adm/style/acp_attachments.html | 20 ++++++++-- phpBB/includes/acp/acp_attachments.php | 54 +++++++++++++++++++++----- phpBB/includes/cache/service.php | 1 + phpBB/language/en/acp/attachments.php | 1 + phpBB/language/en/acp/common.php | 6 ++- 5 files changed, 68 insertions(+), 14 deletions(-) diff --git a/phpBB/adm/style/acp_attachments.html b/phpBB/adm/style/acp_attachments.html index 4a75a9b63b..d938135440 100644 --- a/phpBB/adm/style/acp_attachments.html +++ b/phpBB/adm/style/acp_attachments.html @@ -396,7 +396,10 @@ - {attachments.REAL_FILENAME}
{attachments.COMMENT}
{attachments.L_DOWNLOAD_COUNT}
{L_IN} {L_PRIVATE_MESSAGE}{L_TOPIC}: {attachments.TOPIC_TITLE} + + {L_EXTENSION_GROUP}: {attachments.EXT_GROUP_NAME}{L_NO_EXT_GROUP}
{attachments.L_DOWNLOAD_COUNT}
{L_IN} {L_PRIVATE_MESSAGE} + {attachments.REAL_FILENAME}
{attachments.COMMENT}
{attachments.L_DOWNLOAD_COUNT}
{L_TOPIC}: {attachments.TOPIC_TITLE} + {attachments.FILETIME}
{L_POST_BY_AUTHOR} {attachments.ATTACHMENT_POSTER} {attachments.FILESIZE} @@ -414,6 +417,7 @@ {L_DISPLAY_LOG}:  {S_LIMIT_DAYS} {L_SORT_BY}: {S_SORT_KEY} {S_SORT_DIR} +
-
-

 

{S_FORM_TOKEN} - + +
+ {L_RESYNC_STATS} +
+
+

{L_RESYNC_FILES_STATS_EXPLAIN}
+
+
+
+
+ diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php index 1c3c43c8e9..c62fefae46 100644 --- a/phpBB/includes/acp/acp_attachments.php +++ b/phpBB/includes/acp/acp_attachments.php @@ -1097,8 +1097,8 @@ class acp_attachments // Sorting $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); - $sort_by_text = array('f' => $user->lang['FILENAME'], 't' => $user->lang['FILEDATE'], 's' => $user->lang['FILESIZE'], 'x' => $user->lang['EXTENSION'], 'd' => $user->lang['DOWNLOADS'],'p' => $user->lang['ATTACH_POST_ID'], 'u' => $user->lang['AUTHOR']); - $sort_by_sql = array('f' => 'a.real_filename', 't' => 'a.filetime', 's' => 'a.filesize', 'x' => 'a.extension', 'd' => 'a.download_count', 'p' => 'a.post_msg_id', 'u' => 'u.username'); + $sort_by_text = array('f' => $user->lang['FILENAME'], 't' => $user->lang['FILEDATE'], 's' => $user->lang['FILESIZE'], 'x' => $user->lang['EXTENSION'], 'd' => $user->lang['DOWNLOADS'],'p' => $user->lang['ATTACH_POST_TYPE'], 'u' => $user->lang['AUTHOR']); + $sort_by_sql = array('f' => 'a.real_filename', 't' => 'a.filetime', 's' => 'a.filesize', 'x' => 'a.extension', 'd' => 'a.download_count', 'p' => 'a.in_message', 'u' => 'u.username'); $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); @@ -1109,27 +1109,62 @@ class acp_attachments $attachments_per_page = (int) $config['topics_per_page']; - $num_files = (int) $config['num_files']; - $total_size = (int) $config['upload_dir_size']; + // Handle files stats resync + $action = request_var('action', ''); + $resync_files_stats = false; + if ($action && $action = 'stats') + { + if (!confirm_box(true)) + { + confirm_box(false, $user->lang['RESYNC_FILES_STATS_CONFIRM'], build_hidden_fields(array( + 'i' => $id, + 'mode' => $mode, + 'action' => $action, + ))); + } + else + { + $resync_files_stats = true; + add_log('admin', 'LOG_RESYNC_FILES_STATS'); + } + } - // Check if files statistics is accurate + // Check if files stats are accurate $sql = 'SELECT COUNT(attach_id) as num_files FROM ' . ATTACHMENTS_TABLE . ' WHERE is_orphan = 0'; $result = $db->sql_query($sql, 600); $num_files_real = (int) $db->sql_fetchfield('num_files'); + if ($resync_files_stats === true) + { + set_config('num_files', $num_files_real, true); + } $db->sql_freeresult($result); $sql = 'SELECT SUM(filesize) as upload_dir_size FROM ' . ATTACHMENTS_TABLE . ' WHERE is_orphan = 0'; $result = $db->sql_query($sql, 600); - $total_size_real = (int) $db->sql_fetchfield('upload_dir_size'); + $total_size_real = (float) $db->sql_fetchfield('upload_dir_size'); + if ($resync_files_stats === true) + { + set_config('upload_dir_size', $total_size_real, true); + } $db->sql_freeresult($result); + // Get current files stats + $num_files = (int) $config['num_files']; + $total_size = (float) $config['upload_dir_size']; + + // Issue warning message if files stats are inaccurate if (($num_files != $num_files_real) || ($total_size != $total_size_real)) { - $error[] = sprintf($user->lang['FILES_STAT_WRONG'], $num_files_real, get_formatted_filesize($total_size_real)); + $error[] = sprintf($user->lang['FILES_STATS_WRONG'], $num_files_real, get_formatted_filesize($total_size_real)); + + $template->assign_vars(array( + 'S_ACTION_OPTIONS' => ($auth->acl_get('a_board')) ? true : false, + 'U_ACTION' => $this->u_action,) + ); } // Make sure $start is set to the last page if it exceeds the amount @@ -1207,7 +1242,7 @@ class acp_attachments $row = $attachments_list[$i]; $row['extension'] = strtolower(trim((string) $row['extension'])); - $comment = ($row['attach_comment']) ? str_replace(array("\n", "\r"), array('
', "\n"), $row['attach_comment']) : ''; + $comment = ($row['attach_comment'] && !$row['in_message']) ? str_replace(array("\n", "\r"), array('
', "\n"), $row['attach_comment']) : ''; $display_cat = $extensions[$row['extension']]['display_cat']; $l_downloaded_viewed = ($display_cat == ATTACHMENT_CATEGORY_NONE) ? 'DOWNLOAD_COUNT' : 'VIEWED_COUNT'; $l_download_count = (!isset($row['download_count']) || (int) $row['download_count'] == 0) ? $user->lang[$l_downloaded_viewed . '_NONE'] : (((int) $row['download_count'] == 1) ? sprintf($user->lang[$l_downloaded_viewed], $row['download_count']) : sprintf($user->lang[$l_downloaded_viewed . 'S'], $row['download_count'])); @@ -1216,8 +1251,9 @@ class acp_attachments 'ATTACHMENT_POSTER' => get_username_string('full', (int) $row['poster_id'], (string) $row['username'], (string) $row['user_colour'], (string) $row['username']), 'FILESIZE' => get_formatted_filesize((int) $row['filesize']), 'FILETIME' => $user->format_date((int) $row['filetime']), - 'REAL_FILENAME' => utf8_wordwrap(utf8_basename((string) $row['real_filename']), 40, '
', true), + 'REAL_FILENAME' => (!$row['in_message']) ? utf8_wordwrap(utf8_basename((string) $row['real_filename']), 40, '
', true) : '', 'PHYSICAL_FILENAME' => utf8_basename((string) $row['physical_filename']), + 'EXT_GROUP_NAME' => (!empty($extensions[$row['extension']]['group_name'])) ? $user->lang['EXT_GROUP_' . $extensions[$row['extension']]['group_name']] : '', 'COMMENT' => $comment, 'TOPIC_TITLE' => (!$row['in_message']) ? (string) $row['topic_title'] : '', 'ATTACH_ID' => (int) $row['attach_id'], diff --git a/phpBB/includes/cache/service.php b/phpBB/includes/cache/service.php index 68026c8647..0c01953d55 100644 --- a/phpBB/includes/cache/service.php +++ b/phpBB/includes/cache/service.php @@ -194,6 +194,7 @@ class phpbb_cache_service 'max_filesize' => (int) $row['max_filesize'], 'allow_group' => $row['allow_group'], 'allow_in_pm' => $row['allow_in_pm'], + 'group_name' => $row['group_name'], ); $allowed_forums = ($row['allowed_forums']) ? unserialize(trim($row['allowed_forums'])) : array(); diff --git a/phpBB/language/en/acp/attachments.php b/phpBB/language/en/acp/attachments.php index 9ae250a95a..eede2c5d50 100644 --- a/phpBB/language/en/acp/attachments.php +++ b/phpBB/language/en/acp/attachments.php @@ -62,6 +62,7 @@ $lang = array_merge($lang, array( 'ATTACH_MAX_PM_FILESIZE_EXPLAIN' => 'Maximum size of each file, with 0 being unlimited, attached to a private message.', 'ATTACH_ORPHAN_URL' => 'Orphan attachments', 'ATTACH_POST_ID' => 'Post ID', + 'ATTACH_POST_TYPE' => 'Post type', 'ATTACH_QUOTA' => 'Total attachment quota', 'ATTACH_QUOTA_EXPLAIN' => 'Maximum drive space available for attachments for the whole board, with 0 being unlimited.', 'ATTACH_TO_POST' => 'Attach file to post', diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 11e8e05a56..2a8ed86175 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -239,7 +239,7 @@ $lang = array_merge($lang, array( 'EXPORT_STORE' => 'Store', 'FILES_GONE' => 'Some of the attachments you selected for deletion do not exist. They may have been already deleted. Attachments that did exist were deleted.', - 'FILES_STAT_WRONG' => 'Your files statistics is probably inaccurate and might need to be resynchronised. Actual values: number of attachments » %1$d, total size of attachments » %2$s.', + 'FILES_STATS_WRONG' => 'Your files statistics are probably inaccurate and need to be resynchronised. Actual values: number of attachments = %1$d, total size of attachments = %2$s.', 'GENERAL_OPTIONS' => 'General options', 'GENERAL_SETTINGS' => 'General settings', @@ -281,6 +281,8 @@ $lang = array_merge($lang, array( 'REMIND' => 'Remind', 'RESYNC' => 'Resynchronise', + 'RESYNC_FILES_STATS' => 'Resynchronise files statistics', + 'RESYNC_FILES_STATS_EXPLAIN' => 'Recalculates the total number and size of files attached to posts and private messages.', 'RETURN_TO' => 'Return to…', 'SELECT_ANONYMOUS' => 'Select anonymous user', @@ -367,6 +369,7 @@ $lang = array_merge($lang, array( 'RESET_DATE_CONFIRM' => 'Are you sure you wish to reset the board’s start date?', 'RESET_ONLINE' => 'Reset most users ever online', 'RESET_ONLINE_CONFIRM' => 'Are you sure you wish to reset the most users ever online counter?', + 'RESYNC_FILES_STATS_CONFIRM' => 'Are you sure you wish to resynchronise files statistics?', 'RESYNC_POSTCOUNTS' => 'Resynchronise post counts', 'RESYNC_POSTCOUNTS_EXPLAIN' => 'Only existing posts will be taken into consideration. Pruned posts will not be counted.', 'RESYNC_POSTCOUNTS_CONFIRM' => 'Are you sure you wish to resynchronise post counts?', @@ -671,6 +674,7 @@ $lang = array_merge($lang, array( 'LOG_REFERER_INVALID' => 'Referer validation failed
»Referer was “%1$s”. The request was rejected and the session killed.', 'LOG_RESET_DATE' => 'Board start date reset', 'LOG_RESET_ONLINE' => 'Most users online reset', + 'LOG_RESYNC_FILES_STATS' => 'Files statistics resynchronised', 'LOG_RESYNC_POSTCOUNTS' => 'User post counts resynchronised', 'LOG_RESYNC_POST_MARKING' => 'Dotted topics resynchronised', 'LOG_RESYNC_STATS' => 'Post, topic and user statistics resynchronised', From a3a70e13b5a9e8eaef2bbf7dabe64398b5d10455 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 26 Apr 2011 12:33:15 +0200 Subject: [PATCH 170/170] [ticket/10145] Always recompile all templates when DEBUG_EXTRA is defined. PHPBB3-10145 --- phpBB/includes/template.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index 6347633b14..9ac395344f 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -276,7 +276,7 @@ class template $this->files_template[$handle] = (isset($user->theme['template_id'])) ? $user->theme['template_id'] : 0; $recompile = false; - if (!file_exists($filename) || @filesize($filename) === 0) + if (!file_exists($filename) || @filesize($filename) === 0 || defined('DEBUG_EXTRA')) { $recompile = true; }