function fix_orphan_sf($orphan_sf_sql = '', $show_mess = FALSE)
{
    global $lang;
    $done_mess = '';
    if (!$orphan_sf_sql) {
        $orphan_sf_sql = get_orphan_sf();
    }
    if ($orphan_sf_sql) {
        $sql = 'UPDATE ' . FORUMS_TABLE . " SET\r\n\t\t\t\tforum_parent = 0\r\n\t\t\tWHERE forum_id IN({$orphan_sf_sql})";
        if (!DB()->sql_query($sql)) {
            message_die(GENERAL_ERROR, "Couldn't change subforums data", '', __LINE__, __FILE__, $sql);
        }
        if ($affectedrows = DB()->sql_affectedrows()) {
            $done_mess = "Subforums data corrected. <b>{$affectedrows}</b> orphan subforum(s) moved to root level.";
        }
        if ($show_mess) {
            $message = $done_mess . "<br /><br />" . sprintf($lang['Click_return_forumadmin'], "<a href=\"" . append_sid("admin_forums.php") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.php?pane=right") . "\">", "</a>");
            message_die(GENERAL_MESSAGE, $message);
        }
    }
    return $done_mess;
}
Exemple #2
0
function fix_orphan_sf($orphan_sf_sql = '', $show_mess = FALSE)
{
    global $lang;
    $done_mess = '';
    if (!$orphan_sf_sql) {
        $orphan_sf_sql = get_orphan_sf();
    }
    if ($orphan_sf_sql) {
        $sql = "UPDATE " . BB_FORUMS . " SET forum_parent = 0, show_on_index = 1 WHERE forum_id IN({$orphan_sf_sql})";
        if (!DB()->sql_query($sql)) {
            bb_die('Could not change subforums data');
        }
        if ($affectedrows = DB()->affected_rows()) {
            $done_mess = 'Subforums data corrected. <b>' . $affectedrows . '</b> orphan subforum(s) moved to root level.';
        }
        if ($show_mess) {
            $message = $done_mess . '<br /><br />';
            $message .= sprintf($lang['CLICK_RETURN_FORUMADMIN'], '<a href="admin_forums.php">', '</a>') . '<br /><br />';
            $message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
            bb_die($message);
        }
    }
    return $done_mess;
}