diff options
Diffstat (limited to 'phpBB/includes/acp')
| -rw-r--r-- | phpBB/includes/acp/acp_icons.php | 11 | ||||
| -rw-r--r-- | phpBB/includes/acp/acp_modules.php | 8 | ||||
| -rw-r--r-- | phpBB/includes/acp/acp_permission_roles.php | 47 | ||||
| -rw-r--r-- | phpBB/includes/acp/acp_profile.php | 56 | ||||
| -rw-r--r-- | phpBB/includes/acp/acp_reasons.php | 25 | 
5 files changed, 98 insertions, 49 deletions
diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index f9295e2b47..20b1f56182 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -832,9 +832,10 @@ class acp_icons  					WHERE {$fields}_order = $switch_order_id  						AND {$fields}_id <> $icon_id";  				$db->sql_query($sql); +				$move_executed = (bool) $db->sql_affectedrows();  				// Only update the other entry too if the previous entry got updated -				if ($db->sql_affectedrows()) +				if ($move_executed)  				{  					$sql = "UPDATE $table  						SET {$fields}_order = $switch_order_id @@ -846,6 +847,14 @@ class acp_icons  				$cache->destroy('_icons');  				$cache->destroy('sql', $table); +				if ($request->is_ajax()) +				{ +					$json_response = new \phpbb\json_response; +					$json_response->send(array( +						'success'	=> $move_executed, +					)); +				} +  			break;  		} diff --git a/phpBB/includes/acp/acp_modules.php b/phpBB/includes/acp/acp_modules.php index 100e33044b..c124377ba9 100644 --- a/phpBB/includes/acp/acp_modules.php +++ b/phpBB/includes/acp/acp_modules.php @@ -170,6 +170,14 @@ class acp_modules  					$this->remove_cache_file();  				} +				if ($request->is_ajax()) +				{ +					$json_response = new \phpbb\json_response; +					$json_response->send(array( +						'success'	=> ($move_module_name !== false), +					)); +				} +  			break;  			case 'quickadd': diff --git a/phpBB/includes/acp/acp_permission_roles.php b/phpBB/includes/acp/acp_permission_roles.php index 17e48d6576..aca45575d3 100644 --- a/phpBB/includes/acp/acp_permission_roles.php +++ b/phpBB/includes/acp/acp_permission_roles.php @@ -27,6 +27,7 @@ class acp_permission_roles  	{  		global $db, $user, $auth, $template, $cache, $phpbb_container;  		global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; +		global $request;  		include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);  		include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); @@ -46,6 +47,11 @@ class acp_permission_roles  		$form_name = 'acp_permissions';  		add_form_key($form_name); +		if (!$role_id && in_array($action, array('remove', 'edit', 'move_up', 'move_down'))) +		{ +			trigger_error($user->lang['NO_ROLE_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING); +		} +  		switch ($mode)  		{  			case 'admin_roles': @@ -85,11 +91,6 @@ class acp_permission_roles  			{  				case 'remove': -					if (!$role_id) -					{ -						trigger_error($user->lang['NO_ROLE_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING); -					} -  					$sql = 'SELECT *  						FROM ' . ACL_ROLES_TABLE . '  						WHERE role_id = ' . $role_id; @@ -123,10 +124,6 @@ class acp_permission_roles  				break;  				case 'edit': -					if (!$role_id) -					{ -						trigger_error($user->lang['NO_ROLE_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING); -					}  					// Get role we edit  					$sql = 'SELECT * @@ -273,12 +270,7 @@ class acp_permission_roles  			case 'edit':  				if ($action == 'edit') -				{ -					if (!$role_id) -					{ -						trigger_error($user->lang['NO_ROLE_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING); -					} -					 +				{					  					$sql = 'SELECT *  						FROM ' . ACL_ROLES_TABLE . '  						WHERE role_id = ' . $role_id; @@ -366,7 +358,18 @@ class acp_permission_roles  			case 'move_up':  			case 'move_down': -				$order = request_var('order', 0); +				$sql = 'SELECT role_order +					FROM ' . ACL_ROLES_TABLE . " +					WHERE role_id = $role_id"; +				$result = $db->sql_query($sql); +				$order = $db->sql_fetchfield('role_order'); +				$db->sql_freeresult($result); + +				if ($order === false || ($order == 0 && $action == 'move_up')) +				{ +					break; +				} +				$order = (int) $order;  				$order_total = $order * 2 + (($action == 'move_up') ? -1 : 1);  				$sql = 'UPDATE ' . ACL_ROLES_TABLE . ' @@ -375,6 +378,14 @@ class acp_permission_roles  						AND role_order IN ($order, " . (($action == 'move_up') ? $order - 1 : $order + 1) . ')';  				$db->sql_query($sql); +				if ($request->is_ajax()) +				{ +					$json_response = new \phpbb\json_response; +					$json_response->send(array( +						'success'	=> (bool) $db->sql_affectedrows(), +					)); +				} +  			break;  		} @@ -421,8 +432,8 @@ class acp_permission_roles  				'U_EDIT'			=> $this->u_action . '&action=edit&role_id=' . $row['role_id'],  				'U_REMOVE'			=> $this->u_action . '&action=remove&role_id=' . $row['role_id'], -				'U_MOVE_UP'			=> $this->u_action . '&action=move_up&order=' . $row['role_order'], -				'U_MOVE_DOWN'		=> $this->u_action . '&action=move_down&order=' . $row['role_order'], +				'U_MOVE_UP'			=> $this->u_action . '&action=move_up&role_id=' . $row['role_id'], +				'U_MOVE_DOWN'		=> $this->u_action . '&action=move_down&role_id=' . $row['role_id'],  				'U_DISPLAY_ITEMS'	=> ($row['role_id'] == $display_item) ? '' : $this->u_action . '&display_item=' . $row['role_id'] . '#assigned_to')  			); diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index 4e8145009f..6efd778b12 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -39,11 +39,17 @@ class acp_profile  		$this->tpl_name = 'acp_profile';  		$this->page_title = 'ACP_CUSTOM_PROFILE_FIELDS'; +		$field_id = $request->variable('field_id', 0);  		$action = (isset($_POST['create'])) ? 'create' : request_var('action', '');  		$error = array();  		$s_hidden_fields = ''; +		if (!$field_id && in_array($action, array('delete','activate', 'deactivate', 'move_up', 'move_down', 'edit'))) +		{ +			trigger_error($user->lang['NO_FIELD_ID'] . adm_back_link($this->u_action), E_USER_WARNING); +		} +  		// Define some default values for each field type  		$default_values = array(  			FIELD_STRING	=> array('field_length' => 10, 'field_minlen' => 0, 'field_maxlen' => 20, 'field_validation' => '.*', 'field_novalue' => '', 'field_default_value' => ''), @@ -98,12 +104,6 @@ class acp_profile  		switch ($action)  		{  			case 'delete': -				$field_id = request_var('field_id', 0); - -				if (!$field_id) -				{ -					trigger_error($user->lang['NO_FIELD_ID'] . adm_back_link($this->u_action), E_USER_WARNING); -				}  				if (confirm_box(true))  				{ @@ -210,12 +210,6 @@ class acp_profile  			break;  			case 'activate': -				$field_id = request_var('field_id', 0); - -				if (!$field_id) -				{ -					trigger_error($user->lang['NO_FIELD_ID'] . adm_back_link($this->u_action), E_USER_WARNING); -				}  				$sql = 'SELECT lang_id  					FROM ' . LANG_TABLE . " @@ -256,12 +250,6 @@ class acp_profile  			break;  			case 'deactivate': -				$field_id = request_var('field_id', 0); - -				if (!$field_id) -				{ -					trigger_error($user->lang['NO_FIELD_ID'] . adm_back_link($this->u_action), E_USER_WARNING); -				}  				$sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . "  					SET field_active = 0 @@ -291,7 +279,19 @@ class acp_profile  			case 'move_up':  			case 'move_down': -				$field_order = request_var('order', 0); + +				$sql = 'SELECT field_order +					FROM ' . PROFILE_FIELDS_TABLE . " +					WHERE field_id = $field_id"; +				$result = $db->sql_query($sql); +				$field_order = $db->sql_fetchfield('field_order'); +				$db->sql_freeresult($result); + +				if ($field_order === false || ($field_order == 0 && $action == 'move_up')) +				{ +					break; +				} +				$field_order = (int) $field_order;  				$order_total = $field_order * 2 + (($action == 'move_up') ? -1 : 1);  				$sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . " @@ -299,12 +299,19 @@ class acp_profile  					WHERE field_order IN ($field_order, " . (($action == 'move_up') ? $field_order - 1 : $field_order + 1) . ')';  				$db->sql_query($sql); +				if ($request->is_ajax()) +				{ +					$json_response = new \phpbb\json_response; +					$json_response->send(array( +						'success'	=> (bool) $db->sql_affectedrows(), +					)); +				} +  			break;  			case 'create':  			case 'edit': -				$field_id = request_var('field_id', 0);  				$step = request_var('step', 1);  				$submit = (isset($_REQUEST['next']) || isset($_REQUEST['prev'])) ? true : false; @@ -316,11 +323,6 @@ class acp_profile  				// We are editing... we need to grab basic things  				if ($action == 'edit')  				{ -					if (!$field_id) -					{ -						trigger_error($user->lang['NO_FIELD_ID'] . adm_back_link($this->u_action), E_USER_WARNING); -					} -  					$sql = 'SELECT l.*, f.*  						FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . ' f  						WHERE l.lang_id = ' . $this->edit_lang_id . " @@ -919,8 +921,8 @@ class acp_profile  				'U_EDIT'					=> $this->u_action . "&action=edit&field_id=$id",  				'U_TRANSLATE'				=> $this->u_action . "&action=edit&field_id=$id&step=3",  				'U_DELETE'					=> $this->u_action . "&action=delete&field_id=$id", -				'U_MOVE_UP'					=> $this->u_action . "&action=move_up&order={$row['field_order']}", -				'U_MOVE_DOWN'				=> $this->u_action . "&action=move_down&order={$row['field_order']}", +				'U_MOVE_UP'					=> $this->u_action . "&action=move_up&field_id=$id", +				'U_MOVE_DOWN'				=> $this->u_action . "&action=move_down&field_id=$id",  				'S_NEED_EDIT'				=> $s_need_edit)  			); diff --git a/phpBB/includes/acp/acp_reasons.php b/phpBB/includes/acp/acp_reasons.php index 71e9108c2c..569bb73ab0 100644 --- a/phpBB/includes/acp/acp_reasons.php +++ b/phpBB/includes/acp/acp_reasons.php @@ -26,6 +26,7 @@ class acp_reasons  	{  		global $db, $user, $auth, $template, $cache;  		global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; +		global $request;  		$user->add_lang(array('mcp', 'acp/posting')); @@ -280,7 +281,18 @@ class acp_reasons  			case 'move_up':  			case 'move_down': -				$order = request_var('order', 0); +				$sql = 'SELECT reason_order +					FROM ' . REPORTS_REASONS_TABLE . " +					WHERE reason_id = $reason_id"; +				$result = $db->sql_query($sql); +				$order = $db->sql_fetchfield('reason_order'); +				$db->sql_freeresult($result); + +				if ($order === false || ($order == 0 && $action == 'move_up')) +				{ +					break; +				} +				$order = (int) $order;  				$order_total = $order * 2 + (($action == 'move_up') ? -1 : 1);  				$sql = 'UPDATE ' . REPORTS_REASONS_TABLE . ' @@ -288,6 +300,13 @@ class acp_reasons  					WHERE reason_order IN (' . $order . ', ' . (($action == 'move_up') ? $order - 1 : $order + 1) . ')';  				$db->sql_query($sql); +				if ($request->is_ajax()) +				{ +					$json_response = new \phpbb\json_response; +					$json_response->send(array( +						'success'	=> (bool) $db->sql_affectedrows(), +					)); +				}  			break;  		} @@ -363,8 +382,8 @@ class acp_reasons  				'U_EDIT'		=> $this->u_action . '&action=edit&id=' . $row['reason_id'],  				'U_DELETE'		=> (!$other_reason) ? $this->u_action . '&action=delete&id=' . $row['reason_id'] : '', -				'U_MOVE_UP'		=> $this->u_action . '&action=move_up&order=' . $row['reason_order'], -				'U_MOVE_DOWN'	=> $this->u_action . '&action=move_down&order=' . $row['reason_order']) +				'U_MOVE_UP'		=> $this->u_action . '&action=move_up&id=' . $row['reason_id'], +				'U_MOVE_DOWN'	=> $this->u_action . '&action=move_down&id=' . $row['reason_id'])  			);  		}  		$db->sql_freeresult($result);  | 
