[Function] dosync() and move_topic()

This forum is now closed as part of retiring phpBB2.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
Post Reply
afterlife_69
I've Been Banned!
Posts: 630
Joined: Tue Nov 30, 2004 10:35 am

[Function] dosync() and move_topic()

Post by afterlife_69 » Thu Jul 07, 2005 9:03 am

Dosync is a modified version of the sync() function from the acp and is required by move_topic()

dosync()

Code: Select all

function dosync($type, $id = false)
{
	global $db;

	switch($type)
	{
		case 'all forums':
			$sql = "SELECT forum_id
				FROM " . FORUMS_TABLE;
			if ( !($result = $db->sql_query($sql)) )
			{
				message_die(GENERAL_ERROR, 'Could not get forum IDs', '', __LINE__, __FILE__, $sql);
			}

			while( $row = $db->sql_fetchrow($result) )
			{
				dosync('forum', $row['forum_id']);
			}
		   	break;

		case 'all topics':
			$sql = "SELECT topic_id
				FROM " . TOPICS_TABLE;
			if ( !($result = $db->sql_query($sql)) )
			{
				message_die(GENERAL_ERROR, 'Could not get topic ID', '', __LINE__, __FILE__, $sql);
			}

			while( $row = $db->sql_fetchrow($result) )
			{
				dosync('topic', $row['topic_id']);
			}
			break;
	}
	global $board_config;
	board_stats();
	cache_tree(true);

	return true;
}
Usage:
dosync('all forums');
dosync('all topics');




move_topic()

Code: Select all

function move_topic($topic_id, $new_forum_id)
{
   global $db, $lang, $user_ip, $board_config, $userdata, $phpbb_root_path, $phpEx, $sql;

	$sql = "UPDATE " . TOPICS_TABLE . " 
		SET forum_id = $new_forum_id  
		WHERE topic_id = $topic_id";
	if ( !$db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, 'Could not update old topic', '', __LINE__, __FILE__, $sql);
	}

	$sql = "UPDATE " . POSTS_TABLE . " 
		SET forum_id = $new_forum_id 
		WHERE topic_id = $topic_id";
	if ( !$db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, 'Could not update post topic ids', '', __LINE__, __FILE__, $sql);
	}

	dosync('all forums');
	dosync('all topics');
}
Usage:
move_topic($topic_id, $new_forum_id);

cifroes
Registered User
Posts: 108
Joined: Wed Mar 27, 2002 4:09 pm

Post by cifroes » Sat Sep 24, 2005 9:25 pm

These functions don't work because in dosync there is:

Code: Select all

   board_stats();
   cache_tree(true);
These functions do not exist in any file in phpbb 2.0.17 and it gives an error output. I will try to correct this, but if anyone can help...

Post Reply

Return to “[2.0.x] MOD Writers Discussion”