diff options
| -rw-r--r-- | phpBB/includes/acp/info/acp_prune.php | 2 | ||||
| -rw-r--r-- | phpBB/language/en/common.php | 2 | ||||
| -rw-r--r-- | phpBB/phpbb/db/migration/data/v310/acp_prune_users_module.php | 77 | ||||
| -rw-r--r-- | phpBB/posting.php | 12 | ||||
| -rw-r--r-- | phpBB/viewtopic.php | 8 | ||||
| -rw-r--r-- | tests/test_framework/phpbb_functional_test_case.php | 20 | 
6 files changed, 98 insertions, 23 deletions
diff --git a/phpBB/includes/acp/info/acp_prune.php b/phpBB/includes/acp/info/acp_prune.php index 7498e46cad..0f70d9d638 100644 --- a/phpBB/includes/acp/info/acp_prune.php +++ b/phpBB/includes/acp/info/acp_prune.php @@ -20,7 +20,7 @@ class acp_prune_info  			'version'	=> '1.0.0',  			'modes'		=> array(  				'forums'	=> array('title' => 'ACP_PRUNE_FORUMS', 'auth' => 'acl_a_prune', 'cat' => array('ACP_MANAGE_FORUMS')), -				'users'		=> array('title' => 'ACP_PRUNE_USERS', 'auth' => 'acl_a_userdel', 'cat' => array('ACP_USER_SECURITY')), +				'users'		=> array('title' => 'ACP_PRUNE_USERS', 'auth' => 'acl_a_userdel', 'cat' => array('ACP_CAT_USERS')),  			),  		);  	} diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 360d6be1e0..fba78d34aa 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -210,8 +210,6 @@ $lang = array_merge($lang, array(  	'ERR_CONNECTING_SERVER'				=> 'Error connecting to the server.',  	'ERR_JAB_AUTH'						=> 'Could not authorise on Jabber server.',  	'ERR_JAB_CONNECT'					=> 'Could not connect to Jabber server.', -	'ERR_TEMPLATE_EVENT_LOCATION'		=> 'The specified template event location <em>[%s]</em> is improperly formatted.', -	'ERR_TEMPLATE_COMPILATION'		=> 'The file could not be compiled: %s',  	'ERR_UNABLE_TO_LOGIN'				=> 'The specified username or password is incorrect.',  	'ERR_UNWATCHING'					=> 'An error occurred while trying to unsubscribe.',  	'ERR_WATCHING'						=> 'An error occurred while trying to subscribe.', diff --git a/phpBB/phpbb/db/migration/data/v310/acp_prune_users_module.php b/phpBB/phpbb/db/migration/data/v310/acp_prune_users_module.php new file mode 100644 index 0000000000..ab5b1a535b --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/acp_prune_users_module.php @@ -0,0 +1,77 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* +*/ + +namespace phpbb\db\migration\data\v310; + +class acp_prune_users_module extends \phpbb\db\migration\migration +{ +	public function effectively_installed() +	{ +		$sql = 'SELECT module_id +			FROM ' . MODULES_TABLE . " +			WHERE module_class = 'acp' +				AND module_langname = 'ACP_CAT_USERS'"; +		$result = $this->db->sql_query($sql); +		$acp_cat_users_id = (int) $this->db->sql_fetchfield('module_id'); +		$this->db->sql_freeresult($result); + +		$sql = 'SELECT parent_id +			FROM ' . MODULES_TABLE . " +			WHERE module_class = 'acp' +				AND module_basename = 'acp_prune' +				AND module_mode = 'users'"; +		$result = $this->db->sql_query($sql); +		$acp_prune_users_parent = (int) $this->db->sql_fetchfield('parent_id'); +		$this->db->sql_freeresult($result); + +		// Skip migration if "Users" category has been deleted +		// or the module has already been moved to that category +		return !$acp_cat_users_id || $acp_cat_users_id === $acp_prune_users_parent; +	} + +	static public function depends_on() +	{ +		return array('\phpbb\db\migration\data\v310\beta1'); +	} + +	public function update_data() +	{ +		return array( +			array('custom', array(array($this, 'move_prune_users_module'))), +		); +	} + +	public function move_prune_users_module() +	{ +		$sql = 'SELECT module_id +			FROM ' . MODULES_TABLE . " +			WHERE module_class = 'acp' +				AND module_basename = 'acp_prune' +				AND module_mode = 'users'"; +		$result = $this->db->sql_query($sql); +		$acp_prune_users_id = (int) $this->db->sql_fetchfield('module_id'); +		$this->db->sql_freeresult($result); + +		$sql = 'SELECT module_id +			FROM ' . MODULES_TABLE . " +			WHERE module_class = 'acp' +				AND module_langname = 'ACP_CAT_USERS'"; +		$result = $this->db->sql_query($sql); +		$acp_cat_users_id = (int) $this->db->sql_fetchfield('module_id'); +		$this->db->sql_freeresult($result); + +		if (!class_exists('\acp_modules')) +		{ +			include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext); +		} +		$module_manager = new \acp_modules(); +		$module_manager->module_class = 'acp'; +		$module_manager->move_module($acp_prune_users_id, $acp_cat_users_id); +	} +} diff --git a/phpBB/posting.php b/phpBB/posting.php index 442e1d9782..aee9ba50af 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1213,17 +1213,11 @@ if ($submit || $preview || $refresh)  				meta_refresh(10, $redirect_url);  				$message = ($mode == 'edit') ? $user->lang['POST_EDITED_MOD'] : $user->lang['POST_STORED_MOD'];  				$message .= (($user->data['user_id'] == ANONYMOUS) ? '' : ' '. $user->lang['POST_APPROVAL_NOTIFY']); +				$message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $data['forum_id']) . '">', '</a>'); +				trigger_error($message);  			} -			else -			{ -				meta_refresh(3, $redirect_url); -				$message = ($mode == 'edit') ? 'POST_EDITED' : 'POST_STORED'; -				$message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['VIEW_MESSAGE'], '<a href="' . $redirect_url . '">', '</a>'); -			} - -			$message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $data['forum_id']) . '">', '</a>'); -			trigger_error($message); +			redirect($redirect_url);  		}  	}  } diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 596272636a..61a28940b1 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1564,13 +1564,19 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)  	$edit_allowed = ($user->data['is_registered'] && ($auth->acl_get('m_edit', $forum_id) || (  		$user->data['user_id'] == $poster_id &&  		$auth->acl_get('f_edit', $forum_id) && +		$topic_data['topic_status'] != ITEM_LOCKED &&  		!$row['post_edit_locked'] &&  		($row['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time'])  	))); +	$quote_allowed = $auth->acl_get('m_edit', $forum_id) || ($topic_data['topic_status'] != ITEM_LOCKED && +		($user->data['user_id'] == ANONYMOUS || $auth->acl_get('f_reply', $forum_id)) +	); +  	$delete_allowed = ($user->data['is_registered'] && (($auth->acl_get('m_delete', $forum_id) || ($auth->acl_get('m_softdelete', $forum_id) && $row['post_visibility'] != ITEM_DELETED)) || (  		$user->data['user_id'] == $poster_id &&  		($auth->acl_get('f_delete', $forum_id) || ($auth->acl_get('f_softdelete', $forum_id) && $row['post_visibility'] != ITEM_DELETED)) && +		$topic_data['topic_status'] != ITEM_LOCKED &&  		$topic_data['topic_last_post_id'] == $row['post_id'] &&  		($row['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time']) &&  		// we do not want to allow removal of the last post if a moderator locked it! @@ -1611,7 +1617,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)  		'S_ONLINE'				=> ($poster_id == ANONYMOUS || !$config['load_onlinetrack']) ? false : (($user_cache[$poster_id]['online']) ? true : false),  		'U_EDIT'			=> ($edit_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=edit&f=$forum_id&p={$row['post_id']}") : '', -		'U_QUOTE'			=> ($auth->acl_get('f_reply', $forum_id)) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=quote&f=$forum_id&p={$row['post_id']}") : '', +		'U_QUOTE'			=> ($quote_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=quote&f=$forum_id&p={$row['post_id']}") : '',  		'U_INFO'			=> ($auth->acl_get('m_info', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=post_details&f=$forum_id&p=" . $row['post_id'], true, $user->session_id) : '',  		'U_DELETE'			=> ($delete_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=delete&f=$forum_id&p={$row['post_id']}") : '', diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index d6eb4a632f..c0e58d1104 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -893,9 +893,9 @@ class phpbb_functional_test_case extends phpbb_test_case  	* @param string $message  	* @param array $additional_form_data Any additional form data to be sent in the request  	* @param string $expected Lang var of expected message after posting -	* @return array|null post_id, topic_id if message is 'POST_STORED' +	* @return array|null post_id, topic_id if message is empty  	*/ -	public function create_topic($forum_id, $subject, $message, $additional_form_data = array(), $expected = 'POST_STORED') +	public function create_topic($forum_id, $subject, $message, $additional_form_data = array(), $expected = '')  	{  		$posting_url = "posting.php?mode=post&f={$forum_id}&sid={$this->sid}"; @@ -919,9 +919,9 @@ class phpbb_functional_test_case extends phpbb_test_case  	* @param string $message  	* @param array $additional_form_data Any additional form data to be sent in the request  	* @param string $expected Lang var of expected message after posting -	* @return array|null post_id, topic_id if message is 'POST_STORED' +	* @return array|null post_id, topic_id if message is empty  	*/ -	public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array(), $expected = 'POST_STORED') +	public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array(), $expected = '')  	{  		$posting_url = "posting.php?mode=reply&f={$forum_id}&t={$topic_id}&sid={$this->sid}"; @@ -941,9 +941,9 @@ class phpbb_functional_test_case extends phpbb_test_case  	* @param string $posting_contains  	* @param array $form_data  	* @param string $expected Lang var of expected message after posting -	* @return array|null post_id, topic_id if message is 'POST_STORED' +	* @return array|null post_id, topic_id if message is empty  	*/ -	protected function submit_post($posting_url, $posting_contains, $form_data, $expected = 'POST_STORED') +	protected function submit_post($posting_url, $posting_contains, $form_data, $expected = '')  	{  		$this->add_lang('posting'); @@ -989,13 +989,13 @@ class phpbb_functional_test_case extends phpbb_test_case  		// contained in one of the actual form fields that the browser sees (i.e. it ignores "hidden" inputs)  		// Instead, I send it as a request with the submit button "post" set to true.  		$crawler = self::request('POST', $posting_url, $form_data); -		$this->assertContainsLang($expected, $crawler->filter('html')->text()); -		if ($expected !== 'POST_STORED') +		if ($expected !== '')  		{ -			return; +			$this->assertContainsLang($expected, $crawler->filter('html')->text()); +			return null;  		} -		$url = $crawler->selectLink($this->lang('VIEW_MESSAGE', '', ''))->link()->getUri(); +		$url = $crawler->selectLink($form_data['subject'])->link()->getUri();  		return array(  			'topic_id'	=> $this->get_parameter_from_link($url, 't'),  | 
