diff options
42 files changed, 614 insertions, 995 deletions
diff --git a/phpBB/adm/style/acp_email.html b/phpBB/adm/style/acp_email.html index 885809ffe2..ff52500dca 100644 --- a/phpBB/adm/style/acp_email.html +++ b/phpBB/adm/style/acp_email.html @@ -39,6 +39,10 @@  	<dd><select id="priority" name="mail_priority_flag">{S_PRIORITY_OPTIONS}</select></dd>  </dl>  <dl> +	<dt><label for="banned">{L_MAIL_BANNED}:</label><br /><span>{L_MAIL_BANNED_EXPLAIN}</span></dt> +	<dd><input id="banned" name="mail_banned_flag" type="checkbox" class="radio" /></dd> +</dl> +<dl>  	<dt><label for="send">{L_SEND_IMMEDIATELY}:</label></dt>  	<dd><input id="send" type="checkbox" class="radio" name="send_immediately" checked="checked" /></dd>  </dl> 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/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) -		{ -			// 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'); -			} +		$this->forum_id = (int) $this->topic_data['forum_id']; -			unset($in_fid_ary); +		// Make sure topic is either approved or user authed +		if (!$this->topic_data['topic_approved'] && !$auth->acl_get('m_approve', $this->forum_id)) +		{ +			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)) -			{ -				trigger_error('SORRY_AUTH_READ'); -			} +		// 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 excluded from feed -			if (phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $this->topic_data['forum_options'])) -			{ -				trigger_error('NO_FEED'); -			} +		// Make sure forum is not passworded or user is authed +		if ($this->topic_data['forum_password']) +		{ +			$forum_ids_passworded = $this->get_passworded_forums(); -			// Make sure we can read this forum -			if (!$auth->acl_get('f_read', $this->forum_id)) +			if (isset($forum_ids_passworded[$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/acp/acp_email.php b/phpBB/includes/acp/acp_email.php index b4f0e50029..b4755d3984 100644 --- a/phpBB/includes/acp/acp_email.php +++ b/phpBB/includes/acp/acp_email.php @@ -82,23 +82,48 @@ class acp_email  				{  					if ($group_id)  					{ -						$sql = 'SELECT u.user_email, u.username, u.username_clean, u.user_lang, u.user_jabber, u.user_notify_type -							FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug -							WHERE ug.group_id = ' . $group_id . ' +						$sql_ary = array( +							'SELECT'	=> 'u.user_email, u.username, u.username_clean, u.user_lang, u.user_jabber, u.user_notify_type', +							'FROM'		=> array( +								USERS_TABLE			=> 'u', +								USER_GROUP_TABLE	=> 'ug', +							), +							'WHERE'		=> 'ug.group_id = ' . $group_id . '  								AND ug.user_pending = 0  								AND u.user_id = ug.user_id  								AND u.user_allow_massemail = 1 -								AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ') -							ORDER BY u.user_lang, u.user_notify_type'; +								AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')', +							'ORDER_BY'	=> 'u.user_lang, u.user_notify_type', +						);  					}  					else  					{ -						$sql = 'SELECT username, username_clean, user_email, user_jabber, user_notify_type, user_lang -							FROM ' . USERS_TABLE . ' -							WHERE user_allow_massemail = 1 -								AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ') -							ORDER BY user_lang, user_notify_type'; +						$sql_ary = array( +							'SELECT'	=> 'u.username, u.username_clean, u.user_email, u.user_jabber, u.user_lang, u.user_notify_type', +							'FROM'		=> array( +								USERS_TABLE	=> 'u', +							), +							'WHERE'		=> 'u.user_allow_massemail = 1 +								AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')', +							'ORDER_BY'	=> 'u.user_lang, u.user_notify_type', +						);  					} + +					// Mail banned or not +					if (!isset($_REQUEST['mail_banned_flag'])) +					{ +						$sql_ary['WHERE'] .= ' AND (b.ban_id IS NULL +						        OR b.ban_exclude = 1)'; +						$sql_ary['LEFT_JOIN'] = array( +							array( +								'FROM'	=> array( +									BANLIST_TABLE	=> 'b', +								), +								'ON'	=> 'u.user_id = b.ban_userid', +							), +						); +					} +					$sql = $db->sql_build_query('SELECT', $sql_ary);  				}  				$result = $db->sql_query($sql);  				$row = $db->sql_fetchrow($result); diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index a525efb510..c848039c66 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -395,6 +395,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/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/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 diff --git a/phpBB/includes/auth.php b/phpBB/includes/auth.php index 5b197e93f3..22aca5faf9 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,17 @@ class auth  				while ($subseq = substr($seq, $i, 6))  				{ +					if (isset($seq_cache[$subseq])) +					{ +						$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] .= str_pad(base_convert($subseq, 36, 2), 31, 0, STR_PAD_LEFT); +					$this->acl[$f] .= $converted;  					$i += 6;  				}  			} diff --git a/phpBB/includes/config/config.php b/phpBB/includes/config/config.php index 64fef28cfa..354dc85c03 100644 --- a/phpBB/includes/config/config.php +++ b/phpBB/includes/config/config.php @@ -104,14 +104,27 @@ class phpbb_config implements ArrayAccess, IteratorAggregate, Countable  	}  	/** +	* Removes a configuration option +	* +	* @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, $use_cache = true) +	{ +		unset($this->config[$key]); +	} + +	/**  	* 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;  	} @@ -122,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  bool   $cache     Whether this variable should be cached or if it +	* @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, $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; @@ -142,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 74fb0504ce..a2db4056df 100644 --- a/phpBB/includes/config/db.php +++ b/phpBB/includes/config/db.php @@ -91,16 +91,38 @@ class phpbb_config_db extends phpbb_config  	}  	/** +	* Removes a configuration option +	* +	* @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, $use_cache = true) +	{ +		$sql = 'DELETE FROM ' . $this->table . " +			WHERE config_name = '" . $this->db->sql_escape($key) . "'"; +		$this->db->sql_query($sql); + +		unset($this->config[$key]); + +		if ($use_cache) +		{ +			$this->cache->destroy('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);  	}  	/** @@ -111,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) . "' @@ -138,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');  		} @@ -159,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); @@ -175,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');  		} diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index f910611b76..86c6bc2505 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;  		}  	} @@ -1380,7 +1344,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(); @@ -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;  			}  		}  	} @@ -1644,7 +1586,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) 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'], '<a href="' . $redirect . '">', '</a>');  			} @@ -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..0bb0ef8722 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']]  			);  		} @@ -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 @@ -1465,11 +1464,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 +1485,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 +1496,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 +1538,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 +1690,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 +1758,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 +1794,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 +1830,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 +1847,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 +1871,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 +1986,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 +2148,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 +2239,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 +2326,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 +2370,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 +2399,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 +2407,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 +2420,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/functions_template.php b/phpBB/includes/functions_template.php index d3f9e0dda1..8c58c33b0d 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);  		} diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 81d06344af..124aac18be 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;  	} diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index aad030a7d3..f170dd68eb 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); @@ -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/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 db7bc7c7ea..6c6c5a5532 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))  		{ +			// 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 -				WHERE " . $db->sql_in_set('topic_id', $topic_ids) . ' -					AND forum_id <> 0'; +					WHERE " . $db->sql_in_set('topic_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); -			}  		}  		$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"); @@ -628,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++;  			}  		} @@ -675,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)  			{ @@ -1058,37 +903,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)) +		foreach ($topic_data as $topic_id => $topic_row) +		{ +			if (!isset($search_type) && $topic_row['enable_indexing'])  			{ -				trigger_error('NO_SUCH_SEARCH_MODULE'); -			} +				// Select the search method and do some additional checks to ensure it can actually be utilised +				$search_type = basename($config['search_type']); -			if (!class_exists($search_type)) -			{ -				include("{$phpbb_root_path}includes/search/$search_type.$phpEx"); -			} +				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'; +				$error = false; +				$search = new $search_type($error); +				$search_mode = 'post'; -			if ($error) +				if ($error) +				{ +					trigger_error($error); +				} +			} +			else if (!isset($search_type) && !$topic_row['enable_indexing'])  			{ -				trigger_error($error); +				$search_type = false;  			} -		} -		else -		{ -			$search_type = false; -		} -		foreach ($topic_data as $topic_id => $topic_row) -		{  			$sql_ary = array(  				'forum_id'					=> (int) $to_forum_id,  				'icon_id'					=> (int) $topic_row['icon_id'], @@ -1197,9 +1043,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  				} 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 = '<option value="0"' . (($forum_id == 0) ? ' selected="selected"' : '') . '>' . $user->lang['ALL_FORUMS'] . '</option>'; @@ -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/message_parser.php b/phpBB/includes/message_parser.php index 6d33723292..c6132d86d4 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')")), -			'quote'			=> array('bbcode_id' => 0,	'regexp' => array('#\[quote(?:="(.*?)")?\](.+)\[/quote\]#ise' => "\$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')")), -			'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')")), -			'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')")) +			'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\]#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\]#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\]#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 @@ -1332,7 +1332,9 @@ class parse_message extends bbcode_firstpass  		{  			if ($max_smilies)  			{ -				$num_matches = preg_match_all('#(?<=^|[\n .])(?:' . implode('|', $match) . ')(?![^<>]*>)#', $this->message, $matches); +				// '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);  				if ($num_matches !== false && $num_matches > $max_smilies) @@ -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('(?![^<>]*>)#' . 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));  		}  	} diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php index 249c8e5750..f4fdb50ecd 100644 --- a/phpBB/includes/ucp/ucp_main.php +++ b/phpBB/includes/ucp/ucp_main.php @@ -57,38 +57,29 @@ 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'];  				$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); @@ -100,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)  				{ @@ -158,10 +168,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"))  					);  				} @@ -750,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']);  			}  		} @@ -805,9 +815,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/install/database_update.php b/phpBB/install/database_update.php index 4f2a5966ee..63d191806a 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) +{ +	?> +	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +	<html xmlns="http://www.w3.org/1999/xhtml" dir="<?php echo $lang['DIRECTION']; ?>" lang="<?php echo $lang['USER_LANG']; ?>" xml:lang="<?php echo $lang['USER_LANG']; ?>"> +	<head> + +	<meta http-equiv="content-type" content="text/html; charset=UTF-8" /> +	<meta http-equiv="content-language" content="<?php echo $lang['USER_LANG']; ?>" /> +	<meta http-equiv="content-style-type" content="text/css" /> +	<meta http-equiv="imagetoolbar" content="no" /> + +	<title><?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?></title> + +	<link href="../adm/style/admin.css" rel="stylesheet" type="text/css" media="screen" /> + +	</head> + +	<body> +	<div id="wrap"> +		<div id="page-header"> </div> + +		<div id="page-body"> +			<div id="acp"> +			<div class="panel"> +				<span class="corners-top"><span></span></span> +					<div id="content"> +						<div id="main" class="install-body"> + +		<h1><?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?></h1> + +		<br /> + +		<form action="" method="post" id="select_ga_forum_id"> +			<?php +				if (isset($lang['SELECT_FORUM_GA'])) +				{ +					// Language string is available: +					echo $lang['SELECT_FORUM_GA']; +				} +				else +				{ +					echo 'In phpBB 3.1 the global announcements are linked to forums. Select a forum for your current global announcements (can be moved later):'; +				} +			?> +			<select id="ga_forum_id" name="ga_forum_id"><?php echo make_forum_select(false, false, true, true) ?></select> + +			<input type="submit" name="post" value="<?php echo $lang['SUBMIT']; ?>" class="button1" /> +		</form> +	<?php +	_print_footer(); +	exit; +} +  header('Content-type: text/html; charset=UTF-8');  ?> @@ -1969,6 +2032,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/acp/email.php b/phpBB/language/en/acp/email.php index b8b299bee9..6ce8ddd59b 100644 --- a/phpBB/language/en/acp/email.php +++ b/phpBB/language/en/acp/email.php @@ -52,14 +52,16 @@ $lang = array_merge($lang, array(  	'SEND_TO_GROUP'			=> 'Send to group',  	'SEND_TO_USERS'			=> 'Send to users',  	'SEND_TO_USERS_EXPLAIN'	=> 'Entering names here will override any group selected above. Enter each username on a new line.', -	 + +	'MAIL_BANNED'			=> 'Mail banned users', +	'MAIL_BANNED_EXPLAIN'	=> 'When sending a mass e-mail to a group you can select here whether banned users will also receive the e-mail.',  	'MAIL_HIGH_PRIORITY'	=> 'High',  	'MAIL_LOW_PRIORITY'		=> 'Low',  	'MAIL_NORMAL_PRIORITY'	=> 'Normal',  	'MAIL_PRIORITY'			=> 'Mail priority',  	'MASS_MESSAGE'			=> 'Your message',  	'MASS_MESSAGE_EXPLAIN'	=> 'Please note that you may enter only plain text. All markup will be removed before sending.', -	 +  	'NO_EMAIL_MESSAGE'		=> 'You must enter a message.',  	'NO_EMAIL_SUBJECT'		=> 'You must specify a subject for your message.',  )); diff --git a/phpBB/language/en/acp/posting.php b/phpBB/language/en/acp/posting.php index df573eb853..16e1aaca66 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_EMOTION'			=> 'The smilie “%s” was ignored, as there was no emotion entered.', +	'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.', diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php index 021f5eccb0..bc5a3ab936 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'			=> '<strong>Required</strong> - You must be running at least version 4.3.3 of PHP in order to install phpBB. If <var>safe mode</var> 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 <var>allow_url_fopen</var> is enabled', -	'PHP_URL_FOPEN_SUPPORT_EXPLAIN'	=> '<strong>Optional</strong> - This setting is optional, however certain phpBB functions like off-site avatars will not work properly without it. ', +	'PHP_URL_FOPEN_SUPPORT_EXPLAIN'	=> '<strong>Optional</strong> - 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 <strong>%s</strong> as table prefix.', @@ -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', 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..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 (0, " . 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/posting.php b/phpBB/posting.php index 41559056b9..734e97742c 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -87,9 +87,8 @@ 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)" . -			(($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1'); +				AND f.forum_id = t.forum_id" . +			(($auth->acl_get('m_approve', $forum_id)) ? '' : ' AND t.topic_approved = 1');  	break;  	case 'quote': @@ -116,9 +115,8 @@ 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)" . -				(($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND p.post_approved = 1'); +				AND f.forum_id = t.forum_id" . +				(($auth->acl_get('m_approve', $forum_id)) ? '' : ' AND p.post_approved = 1');  	break;  	case 'smilies': @@ -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..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'])  					{ @@ -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/memberlist_im.html b/phpBB/styles/prosilver/template/memberlist_im.html index 29c4cf1b91..88c57eb8c5 100644 --- a/phpBB/styles/prosilver/template/memberlist_im.html +++ b/phpBB/styles/prosilver/template/memberlist_im.html @@ -39,7 +39,7 @@  			<dt> </dt>  			<dd><a href="{U_AIM_CONTACT}">{L_IM_ADD_CONTACT}</a></dd>  			<dd><a href="{U_AIM_MESSAGE}">{L_IM_SEND_MESSAGE}</a></dd> -			<dd><a href="http://www.aim.com/download.adp">{L_IM_DOWNLOAD_APP}</a> | <a href="http://aimexpress.oscar.aol.com/aimexpress/launch.adp?Brand=AIM">{L_IM_AIM_EXPRESS}</a></dd> +			<dd><a href="http://www.aim.com">{L_IM_DOWNLOAD_APP}</a> | <a href="http://www.aim.com/products/express">{L_IM_AIM_EXPRESS}</a></dd>  		</dl>  	<!-- ENDIF --> 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 @@  						<!-- IF searchresults.S_TOPIC_UNAPPROVED or searchresults.S_POSTS_UNAPPROVED --><a href="{searchresults.U_MCP_QUEUE}">{searchresults.UNAPPROVED_IMG}</a> <!-- ENDIF -->  						<!-- IF searchresults.S_TOPIC_REPORTED --><a href="{searchresults.U_MCP_REPORT}">{REPORTED_IMG}</a><!-- ENDIF --><br />  						<!-- IF searchresults.PAGINATION --><strong class="pagination"><span>{searchresults.PAGINATION}</span></strong><!-- ENDIF --> -						{L_POST_BY_AUTHOR} {searchresults.TOPIC_AUTHOR_FULL} » {searchresults.FIRST_POST_TIME} -						<!-- IF not searchresults.S_TOPIC_GLOBAL -->{L_IN} <a href="{searchresults.U_VIEW_FORUM}">{searchresults.FORUM_TITLE}</a><!-- ELSE --> ({L_GLOBAL})<!-- ENDIF --> +						{L_POST_BY_AUTHOR} {searchresults.TOPIC_AUTHOR_FULL} » {searchresults.FIRST_POST_TIME} » {L_IN} <a href="{searchresults.U_VIEW_FORUM}">{searchresults.FORUM_TITLE}</a>  					</dt>  					<dd class="posts">{searchresults.TOPIC_REPLIES}</dd>  					<dd class="views">{searchresults.TOPIC_VIEWS}</dd> @@ -102,12 +101,8 @@  			<dt class="author">{L_POST_BY_AUTHOR} {searchresults.POST_AUTHOR_FULL}</dt>  			<dd>{searchresults.POST_DATE}</dd>  			<dd> </dd> -			<!-- IF searchresults.FORUM_TITLE --> -				<dd>{L_FORUM}: <a href="{searchresults.U_VIEW_FORUM}">{searchresults.FORUM_TITLE}</a></dd> -				<dd>{L_TOPIC}: <a href="{searchresults.U_VIEW_TOPIC}">{searchresults.TOPIC_TITLE}</a></dd> -			<!-- ELSE --> -				<dd>{L_GLOBAL}: <a href="{searchresults.U_VIEW_TOPIC}">{searchresults.TOPIC_TITLE}</a></dd> -			<!-- ENDIF --> +			<dd>{L_FORUM}: <a href="{searchresults.U_VIEW_FORUM}">{searchresults.FORUM_TITLE}</a></dd> +			<dd>{L_TOPIC}: <a href="{searchresults.U_VIEW_TOPIC}">{searchresults.TOPIC_TITLE}</a></dd>  			<dd>{L_REPLIES}: <strong>{searchresults.TOPIC_REPLIES}</strong></dd>  			<dd>{L_VIEWS}: <strong>{searchresults.TOPIC_VIEWS}</strong></dd>  		</dl> 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 @@  					<!-- IF topicrow.S_TOPIC_REPORTED --><a href="{topicrow.U_MCP_REPORT}">{REPORTED_IMG}</a><!-- ENDIF --><br />  					<!-- IF topicrow.PAGINATION --><strong class="pagination"><span>{topicrow.PAGINATION}</span></strong><!-- ENDIF -->  					<!-- IF topicrow.ATTACH_ICON_IMG -->{topicrow.ATTACH_ICON_IMG} <!-- ENDIF -->{L_POST_BY_AUTHOR} {topicrow.TOPIC_AUTHOR_FULL} » {topicrow.FIRST_POST_TIME} +					<!-- IF topicrow.S_POST_GLOBAL and FORUM_ID != topicrow.FORUM_ID --> » {L_IN} <a href="{topicrow.U_VIEW_FORUM}">{topicrow.FORUM_NAME}</a><!-- ENDIF -->  				</dt>  				<dd class="posts">{topicrow.REPLIES} <dfn>{L_REPLIES}</dfn></dd>  				<dd class="views">{topicrow.VIEWS} <dfn>{L_VIEWS}</dfn></dd> diff --git a/phpBB/styles/subsilver2/template/memberlist_im.html b/phpBB/styles/subsilver2/template/memberlist_im.html index 7b650dda70..329c323ffa 100644 --- a/phpBB/styles/subsilver2/template/memberlist_im.html +++ b/phpBB/styles/subsilver2/template/memberlist_im.html @@ -19,7 +19,7 @@  	<!-- IF S_SEND_AIM -->  		<tr> -			<td class="row1" colspan="2" align="center"><br /><a class="gen" href="{U_AIM_CONTACT}">{L_IM_ADD_CONTACT}</a><br /><a class="gen" href="{U_AIM_MESSAGE}">{L_IM_SEND_MESSAGE}</a><br /><br /><a class="gensmall" href="http://www.aim.com/download.adp">{L_IM_DOWNLOAD_APP}</a> | <a class="gensmall" href="http://aimexpress.oscar.aol.com/aimexpress/launch.adp?Brand=AIM">{L_IM_AIM_EXPRESS}</a> </td> +			<td class="row1" colspan="2" align="center"><br /><a class="gen" href="{U_AIM_CONTACT}">{L_IM_ADD_CONTACT}</a><br /><a class="gen" href="{U_AIM_MESSAGE}">{L_IM_SEND_MESSAGE}</a><br /><br /><a class="gensmall" href="http://www.aim.com">{L_IM_DOWNLOAD_APP}</a> | <a class="gensmall" href="http://www.aim.com/products/express">{L_IM_AIM_EXPRESS}</a> </td>  		</tr>  		<tr>  			<td class="cat" colspan="2" align="center"> </td> 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 @@  				<!-- IF searchresults.PAGINATION -->  					<p class="gensmall"> [ {GOTO_PAGE_IMG}{L_GOTO_PAGE}: {searchresults.PAGINATION} ] </p>  				<!-- ENDIF --> -				<!-- IF searchresults.S_TOPIC_GLOBAL --> -					<p class="gensmall">{L_GLOBAL}</p> -				<!-- ELSE --> -					<p class="gensmall">{L_IN} <a href="{searchresults.U_VIEW_FORUM}">{searchresults.FORUM_TITLE}</a></p> -				<!-- ENDIF --> +				<p class="gensmall">{L_IN} <a href="{searchresults.U_VIEW_FORUM}">{searchresults.FORUM_TITLE}</a></p>  			</td>  			<td class="row2" width="100" align="center"><p class="topicauthor">{searchresults.TOPIC_AUTHOR_FULL}</p></td>  			<td class="row1" width="50" align="center"><p class="topicdetails">{searchresults.TOPIC_REPLIES}</p></td> @@ -84,7 +80,7 @@  		<!-- IF searchresults.S_IGNORE_POST -->  			<td class="gensmall" colspan="2" height="25" align="center">{searchresults.L_IGNORE_POST}</td>  		<!-- ELSE --> -				<td colspan="2" height="25"><p class="topictitle"><a name="p{searchresults.POST_ID}" id="p{searchresults.POST_ID}"></a> <!-- IF searchresults.FORUM_TITLE -->{L_FORUM}: <a href="{searchresults.U_VIEW_FORUM}">{searchresults.FORUM_TITLE}</a><!-- ELSE -->{L_GLOBAL}<!-- ENDIF -->   {L_TOPIC}: <a href="{searchresults.U_VIEW_TOPIC}">{searchresults.TOPIC_TITLE}</a> </p></td> +				<td colspan="2" height="25"><p class="topictitle"><a name="p{searchresults.POST_ID}" id="p{searchresults.POST_ID}"></a> {L_FORUM}: <a href="{searchresults.U_VIEW_FORUM}">{searchresults.FORUM_TITLE}</a>   {L_TOPIC}: <a href="{searchresults.U_VIEW_TOPIC}">{searchresults.TOPIC_TITLE}</a> </p></td>  			</tr>  			<tr class="row1">  				<td width="150" align="center" valign="middle"><b class="postauthor">{searchresults.POST_AUTHOR_FULL}</b></td> 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 @@  					<!-- IF topicrow.PAGINATION -->  						<p class="gensmall"> [ {GOTO_PAGE_IMG}{L_GOTO_PAGE}: {topicrow.PAGINATION} ] </p>  					<!-- ENDIF --> +					<!-- IF topicrow.S_POST_GLOBAL and FORUM_ID != topicrow.FORUM_ID --><p class="gensmall">{L_IN} <a href="{topicrow.U_VIEW_FORUM}">{topicrow.FORUM_NAME}</a></p><!-- ENDIF -->  				</td>  				<td class="row2" width="130" align="center"><p class="topicauthor">{topicrow.TOPIC_AUTHOR_FULL}</p></td>  				<td class="row1" width="50" align="center"><p class="topicdetails">{topicrow.REPLIES}</p></td> diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 16d8b56d88..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); @@ -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.*', @@ -359,14 +359,24 @@ 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)); + +	$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 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 +			(' . $db->sql_in_set('t.forum_id', $g_forum_ary) . ' +				AND t.topic_type = ' . POST_GLOBAL . ')',  		'ORDER_BY'	=> 't.topic_time DESC',  	)); @@ -377,16 +387,35 @@ if ($forum_data['forum_type'] == FORUM_POST)  		$rowset[$row['topic_id']] = $row;  		$announcement_list[] = $row['topic_id']; -		if ($row['topic_type'] == POST_GLOBAL) +		if ($forum_id != $row['forum_id'])  		{ -			$global_announce_list[$row['topic_id']] = true; +			$topics_count++; +			$global_announce_forums[] = $row['forum_id'];  		} -		else +	} +	$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))  		{ -			$topics_count--; +			$forum_tracking_info[$row['forum_id']] = $row['mark_time'];  		} +		$db->sql_freeresult($result);  	} -	$db->sql_freeresult($result);  }  // If the user is trying to reach late pages, start searching from the end @@ -546,45 +575,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']) +		$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; +	} + +	if ($config['load_db_lastread'] && $user->data['is_registered']) +	{ +		foreach ($topic_forum_list as $f_id => $topic_row)  		{ -			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); -			} +			$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']) +	} +	else if ($config['load_anon_lastread'] || $user->data['is_registered']) +	{ +		foreach ($topic_forum_list as $f_id => $topic_row)  		{ -			foreach ($topic_forum_list as $f_id => $topic_row) -			{ -				$topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics'], false); -			} +			$topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics']);  		} - -		unset($topic_forum_list);  	} -	else + +	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; @@ -622,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']), @@ -649,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), @@ -660,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, @@ -681,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) 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  { diff --git a/tests/config/config_test.php b/tests/config/config_test.php index 73a365c847..9c91d9eb87 100644 --- a/tests/config/config_test.php +++ b/tests/config/config_test.php @@ -109,4 +109,12 @@ 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')); + +		$config->delete('foo'); +		$this->assertFalse(isset($config['foo'])); +	}  } diff --git a/tests/config/db_test.php b/tests/config/db_test.php index e0d5252f19..e817545a54 100644 --- a/tests/config/db_test.php +++ b/tests/config/db_test.php @@ -125,4 +125,42 @@ 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'); +		$this->cache->checkVarUnset($this, 'foo'); +		$this->assertFalse(isset($this->config['foo'])); + +		// re-read config and populate cache +		$cache2 = new phpbb_mock_cache; +		$config2 = new phpbb_config_db($this->db, $cache2, 'phpbb_config'); +		$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']); +	}  }  | 
