MyBB Community Forums

Full Version: find_replace_templatesets problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
When installing this works fine:

find_replace_templatesets('usercp_nav_misc', '#'.preg_quote('</tbody>').'#', '<tr><td class="trow1 smalltext"><a href="usercp.php?action=newapplication" class="usercp_nav_item usercp_nav_viewprofile">Apply For Clan</a></td></tr></tbody>');

When I add the following to uninstall function in my plugin, It doesn't change it back:

require_once MYBB_ROOT."inc/adminfunctions_templates.php";
	find_replace_templatesets('usercp_nav_misc', '#'.preg_quote('<tr><td class="trow1 smalltext"><a href="usercp.php?action=newapplication" class="usercp_nav_item usercp_nav_viewprofile">Apply For Clan</a></td></tr></tbody>').'#', '</tbody>');

There was a topic on this that I referrered to. Can someone help me?
nvm, made better function which does the job:

	public function replace_temp_set($title,$find,$replace) {
		global $db;
		$title = $db->escape_string( $title );
		$query = $db->simple_select("templates", "*", "title='$title' AND sid='-2'");
		if( $db->num_rows( $query ) > 0 ) {
			$rows = $db->fetch_array( $query );
			$temp = str_replace($find,$replace, $rows['template']);
			$updatetemp = array("template" => $db->escape_string($temp), "dateline" => TIME_NOW);
			$db->update_query("templates", $updatetemp, "title='$title'");
		}
	}
I am having same issue with my plugin.
wonder if that function will work.
$query = $db->simple_select("templates", "*", "title='$title' AND sid='-2'");

Should that be

$query = $db->simple_select("templates", "*", "title='$title' AND sid!='-2'");

If you change the master templates you can't revert.