Exemplo n.º 1
0
function integrate_character_post_count($msgOptions, $topicOptions, $posterOptions, $message_columns, $message_parameters)
{
    if ($msgOptions['approved'] && !empty($posterOptions['char_id']) && !empty($posterOptions['update_post_count'])) {
        updateCharacterData($posterOptions['char_id'], ['posts' => '+']);
    }
}
Exemplo n.º 2
0
function merge_char_accounts($source, $dest)
{
    global $user_profile, $sourcedir, $smcFunc;
    if ($source == $dest) {
        return 'no_same';
    }
    $loaded = loadMemberData(array($source, $dest));
    if (!in_array($source, $loaded) || !in_array($dest, $loaded)) {
        return 'no_exist';
    }
    if ($user_profile[$source]['id_group'] == 1 || in_array('1', explode(',', $user_profile[$source]['additional_groups']))) {
        return 'no_merge_admin';
    }
    // Work out which the main characters are.
    $source_main = 0;
    $dest_main = 0;
    foreach ($user_profile[$source]['characters'] as $id_char => $char) {
        if ($char['is_main']) {
            $source_main = $id_char;
            break;
        }
    }
    foreach ($user_profile[$dest]['characters'] as $id_char => $char) {
        if ($char['is_main']) {
            $dest_main = $id_char;
            break;
        }
    }
    if (empty($source_main) || empty($dest_main)) {
        return 'no_main';
    }
    // Move characters
    $smcFunc['db_query']('', '
		UPDATE {db_prefix}characters
		SET id_member = {int:dest}
		WHERE id_member = {int:source}
			AND id_character != {int:source_main}', array('source' => $source, 'source_main' => $source_main, 'dest' => $dest, 'dest_main' => $dest_main));
    // Move posts over - main
    $smcFunc['db_query']('', '
		UPDATE {db_prefix}messages
		SET id_member = {int:dest},
			id_character = {int:dest_main}
		WHERE id_member = {int:source}
			AND id_character = {int:source_main}', array('source' => $source, 'source_main' => $source_main, 'dest' => $dest, 'dest_main' => $dest_main));
    // Move posts over - characters (i.e. whatever's left)
    $smcFunc['db_query']('', '
		UPDATE {db_prefix}messages
		SET id_member = {int:dest}
		WHERE id_member = {int:source}', array('source' => $source, 'dest' => $dest));
    // Fix post counts of destination accounts
    $total_posts = 0;
    foreach ($user_profile[$source]['characters'] as $char) {
        $total_posts += $char['posts'];
    }
    if (!empty($total_posts)) {
        updateMemberData($dest, array('posts' => 'posts + ' . $total_posts));
    }
    if (!empty($user_profile[$source]['characters'][$source_main]['posts'])) {
        updateCharacterData($dest_main, array('posts' => 'posts + ' . $user_profile[$source]['characters'][$source_main]['posts']));
    }
    // Reassign topics
    $smcFunc['db_query']('', '
		UPDATE {db_prefix}topics
		SET id_member_started = {int:dest}
		WHERE id_member_started = {int:source}', array('source' => $source, 'dest' => $dest));
    $smcFunc['db_query']('', '
		UPDATE {db_prefix}topics
		SET id_member_updated = {int:dest}
		WHERE id_member_updated = {int:source}', array('source' => $source, 'dest' => $dest));
    // Move PMs - sent items
    $smcFunc['db_query']('', '
		UPDATE {db_prefix}personal_messages
		SET id_member_from = {int:dest}
		WHERE id_member_from = {int:source}', array('source' => $source, 'dest' => $dest));
    // Move PMs - received items
    // First we have to get all the existing recipient rows
    $rows = [];
    $request = $smcFunc['db_query']('', '
		SELECT id_pm, bcc, is_read, is_new, deleted
		FROM {db_prefix}pm_recipients
		WHERE id_member = {int:source}', array('source' => $source));
    while ($row = $smcFunc['db_fetch_assoc']($request)) {
        $rows[] = array('id_pm' => $row['id_pm'], 'id_member' => $dest, 'bcc' => $row['bcc'], 'is_read' => $row['is_read'], 'is_new' => $row['is_new'], 'deleted' => $row['deleted'], 'is_inbox' => 1);
    }
    $smcFunc['db_free_result']($request);
    if (!empty($rows)) {
        $smcFunc['db_insert']('ignore', '{db_prefix}pm_recipients', array('id_pm' => 'int', 'id_member' => 'int', 'bcc' => 'int', 'is_read' => 'int', 'is_new' => 'int', 'deleted' => 'int', 'is_inbox' => 'int'), $rows, array('id_pm', 'id_member'));
    }
    // Delete the source user
    require_once $sourcedir . '/Subs-Members.php';
    deleteMembers($source);
    return true;
}