MyBB Community Forums

Full Version: Redirect to thread
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello MyBB Community,
im using a plugin that called newpoints edit
basiclly it let me edit users points through postbit,
after editing user points it's redirect me to the user profile of the user that i've edit,
i want to know how can i redirect to the same thread that i've been before.

Code :

<?php
/*********************************************************************************************
+ Newpoints Edit v0.2 : A Plugin for MyBB 1.4 and 1.6
---
	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
**********************************************************************************************
*/
if(!defined("IN_MYBB"))
{
	die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

function newpoints_edit_info()
{
	return array(
		"name"			=> "Newpoints Edit",
		"description"	=> "Allows you to edit newpoints of any user.",
		"website"		=> "http://yaldaram.com",
		"author"		=> "Yaldaram",
		"authorsite"	=> "http://yaldaram.com",
		"version"		=> "0.2",
		"compatibility" => "14*,16*,18*"
	);

}
function newpoints_edit_install()
{
	global $db, $mybb;

	$newpoints_edit_group = array(
		"gid"			=> "NULL",
		"name"			=> "newpoints_edit",
		"title" 		=> "Newpoints Edit",
		"description"	=> "Settings for the plugin.",
		"disporder"		=> "1",
		"isdefault"		=> "no",
	);
	$db->insert_query("settinggroups", $newpoints_edit_group);
	$gid = $db->insert_id();
	
	$newpoints_edit_setting_1 = array(
		"sid"			=> "NULL",
		"name"			=> "newpoints_edit_power",
		"title"			=> "Power",
		"description"	=> "Select Yes if you really wants this plugin to run.",
		"optionscode"	=> "yesno",
		"value"			=> "1",
		"disporder"		=> "1",
		"gid"			=> intval($gid),
	);

	$db->insert_query("settings", $newpoints_edit_setting_1);

	$newpoints_edit_setting_2 = array(
		"sid"			=> "NULL",
		"name"			=> "newpoints_edit_group",
		"title"			=> "MOD_Usergroups",
		"description"	=> "Specify Usergroup IDs you wish to allow them to edit Newpoints.(Usually Moderators and Admins) Separate with , if more then.",
		"optionscode"	=> "text",
		"value"			=> "3,4",
		"disporder"		=> "2",
		"gid"			=> intval($gid),
	);

	$db->insert_query("settings", $newpoints_edit_setting_2);
	
	$newpoints_edit_setting_3 = array(
		"sid"			=> "NULL",
		"name"			=> "newpoints_edit_self",
		"title"			=> "Self_Editing",
		"description"	=> "Would you like to allow above usergroups to edit their own Newpoints ?",
		"optionscode"	=> "yesno",
		"value"			=> "1",
		"disporder"		=> "3",
		"gid"			=> intval($gid),
	);

	$db->insert_query("settings", $newpoints_edit_setting_3);

	rebuild_settings();

	// Insert Templates
	require MYBB_ROOT."/inc/adminfunctions_templates.php";
	$template = array(
		"title"		=> "newpoints_edit_page",
		"template"	=> '<html>
<head>
<title>{$mybb->settings[\\\'bbname\\\']} - {$lang->edit_newpoints}</title>
{$headerinclude}
</head>
<body>
{$header}
<form action="newpoints.php" method="post" enctype="multipart/form-data" name="input">
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<table border="0" cellspacing="{$theme[\\\'borderwidth\\\']}" cellpadding="{$theme[\\\'tablespace\\\']}" class="tborder">
<tr>
<td class="thead" colspan="2"><strong>{$lang->edit_newpoints_of} {$user_username}</strong></td>
</tr>
<tr>
<td class="trow1" width="25%">
<strong>{$lang->current_newpoints}</strong>
</td>
<td class="trow1" width="75%">
<i>{$user_newpoints}</i><br />
<span class="smalltext">{$lang->edit_using_form}</span>
</td>
</tr>
<tr>
<td class="trow2" width="25%">
<strong>{$lang->edit_form}</strong>
</td>
<td class="trow2" width="75%">
<input type="text" class="textbox" name="points" size="40" maxlength="85" value="{$user_newpoints}" tabindex="1" />
</td>
</tr>
<tr>
<td class="thead" colspan="2">
<div style="text-align:center"><input type="submit" class="button" name="submit" value="{$lang->submit}" tabindex="4" accesskey="s" /></div>
</td>
</tr>
</table>
<input type="hidden" name="action" value="do_edit" />
<input type="hidden" name="uid" value="{$mybb->input[\\\'uid\\\']}" />
<input type="hidden" name="do_uid" value="{$mybb->user[\\\'uid\\\']}" />
</form>
{$footer}
</body>
</html>',
		"sid"		=> -1
	);
	$db->insert_query("templates", $template);

	find_replace_templatesets("postbit", "#".preg_quote('{$post[\'newpoints_postbit\']}')."#i", '{\$post[\'newpoints_postbit\']}{\$post[\'newpoints_edit\']}');
	find_replace_templatesets("postbit_classic", "#".preg_quote('{$post[\'newpoints_postbit\']}')."#i", '{\$post[\'newpoints_postbit\']}{\$post[\'newpoints_edit\']}');
}

function newpoints_edit_is_installed()
{
	global $db;
	$query = $db->simple_select("settinggroups", "COUNT(*) as rows", "name='newpoints_edit'");
	$rows = $db->fetch_field($query, "rows");
	if($rows > 0)
	{
		return TRUE;
	}
	
	return FALSE;
}

function newpoints_edit_activate()
{
}

function newpoints_edit_deactivate()
{
}

function newpoints_edit_uninstall()
{
	global $db, $mybb;
	require MYBB_ROOT."/inc/adminfunctions_templates.php";
	find_replace_templatesets("postbit", "#".preg_quote('{$post[\'newpoints_edit\']}')."#i", '', 0);
	find_replace_templatesets("postbit_classic", "#".preg_quote('{$post[\'newpoints_edit\']}')."#i", '', 0);

	$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='newpoints_edit_page'");
	$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='newpoints_edit'");
	$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='newpoints_edit_power'");
	$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='newpoints_edit_group'");
    rebuild_settings();
}

$plugins->add_hook("postbit", "newpoints_edit");
function newpoints_edit(&$post)
{
	global $mybb, $lang, $templates;
	$power = $mybb->settings['newpoints_edit_power'];
	$groups = explode(",",$mybb->settings['newpoints_edit_group']);
	$self_editing = $mybb->settings['newpoints_edit_self'];
	if ($power != "0")
	{
		$lang->load("newpoints_edit");
		if (in_array($mybb->user['additionalgroups'],$groups) || in_array($mybb->user['usergroup'],$groups) && $self_editing != "1" && $post['uid'] == $mybb->user['uid'])
		{
			$post['newpoints_edit'] = '';
		}
		elseif (in_array($mybb->user['usergroup'],$groups) || in_array($mybb->user['additionalgroups'],$groups))
		{
			$post['newpoints_edit'] = '[<a href="newpoints.php?action=edit&amp;uid='.$post['uid'].'">'.$lang->edit_newpoints_postbit.'</a>]';
		}
	}
}

$plugins->add_hook("newpoints_begin", "newpoints_edit_begin");
function newpoints_edit_begin()
{
	global $db, $mybb, $lang, $templates, $theme, $header, $footer, $headerinclude, $newpoints_edit_page;
	
	$action = $mybb->input['action'];
	$lang->load("newpoints_edit");
	if ($action == "edit")
	{
		$power = $mybb->settings['newpoints_edit_power'];
		if ($power != "1")
		{
			error($lang->newpoints_disabled);
		}
		
		$groups = explode(",",$mybb->settings['newpoints_edit_group']);
		if (!in_array($mybb->user['usergroup'],$groups) && !in_array($mybb->user['additionalgroups'],$groups))
		{
			error($lang->error_no_permission);
		}
		
		$self_editing = $mybb->settings['newpoints_edit_self'];
		$uid = intval($mybb->input['uid']);
		if ($self_editing != "1" && $uid == $mybb->user['uid'])
		{
			error($lang->no_permission_self_editing);
		}
		
		add_breadcrumb($lang->edit_newpoints, "newpoints.php?action=edit");
		
		$user = get_user($uid);
		$user_newpoints = intval($user['newpoints']);
		$user_username = htmlspecialchars_uni($user['username']);
		
		eval("\$newpoints_edit_page = \"".$templates->get("newpoints_edit_page")."\";");
		output_page($newpoints_edit_page);
	}
	elseif ($action == "do_edit")
	{
		// Verify incoming post request.
		verify_post_check($mybb->input['my_post_key']);
		
		$power = $mybb->settings['newpoints_edit_power'];
		if ($power != "1")
		{
			error($lang->newpoints_disabled);
		}
		
		$groups = explode(",",$mybb->settings['newpoints_edit_group']);
		if (!in_array($mybb->user['usergroup'],$groups) && !in_array($mybb->user['additionalgroups'],$groups))
		{
			error($lang->error_no_permission);
		}
		
		$self_editing = $mybb->settings['newpoints_edit_self'];
		$uid = intval($mybb->input['uid']);
		if ($self_editing != "1" && $uid == $mybb->user['uid'])
		{
			error($lang->no_permission_self_editing);
		}
		
		$uid = intval($mybb->input['uid']);
		
		$updates =  array(
			"newpoints" => floatval($mybb->input['points'])
		);
		$db->update_query("users", $updates, "uid='{$uid}'");
		redirect("member.php?action=profile&amp;uid={$uid}", $lang->newpoints_edited_success);
	}
}
?>


it supposed to be simple to people that know php im not proffesional with php
but i know that this is somthing to change in the bottom of the code there is the redirect there.


Thanks, Afik.