<?php
/************************************************************************/
/* Maximus CMS: Web Portal System                                       */
/* ==============================                                       */
/*                                                                      */
/* Copyright (c) 2002 - 2006                                            */
/* http://www.php-maximus.fr                                            */
/* dev@php-maximus.org                                                  */
/*                                                                      */
/* 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 2 of the License.       */
/************************************************************************/
/* Based on PHP-NUKE: Web Portal System                                 */
/************************************************************************/
if (!defined('ADMIN_ALLOW') && !defined('ADMIN_MAX')) {
    Header("Location: index.php");
}

    $catid = $db->XMFnum($catid);
    $result = $db->sql_query("select title from ".TABLE_STORIES_CAT." where catid='$catid'");
    list($title) = $db->sql_fetchrow($result);
    incoh();
    GraphicAdmin();
    Max_OpenTable();
    echo "<center><font class='title'><b>"._CATEGORIESADMIN."</b></font></center>";
    Max_CloseTable();
    echo "<br />";
    Max_OpenTable();
    echo "<center><font class=\"option\"><b>"._MOVESTORIES."</b></font><br /><br />";
    if (!$newcat) {
        echo ""._ALLSTORIES." <b>$title</b> "._WILLBEMOVED."<br /><br />";
        $selcat = $db->sql_query("select catid, title from ".TABLE_STORIES_CAT."");
        echo "<form action=\"".$admin_file.".php\" method=\"post\">";
        echo "<b>"._SELECTNEWCAT.":</b> ";
        echo "<select name=\"newcat\">";
        echo "<option name=\"newcat\" value=\"0\">"._ARTICLES."</option>";
        while(list($newcat, $title) = $db->sql_fetchrow($selcat)) {
                echo "<option name=\"newcat\" value=\"$newcat\">$title</option>";
        }
        echo "</select>";
        echo "<input type=\"hidden\" name=\"catid\" value=\"$catid\">";
        echo "<input type=\"hidden\" name=\"op\" value=\"NoMoveCategory\">";
        echo "<input type=\"submit\" value=\""._OK."\">";
        echo "</form>";
    } else {
        $resultm = $db->sql_query("select sid from ".TABLE_STORIES." where catid='$catid'");
        while(list($sid) = $db->sql_fetchrow($resultm)) {
        $sid = $db->XMFnum($sid);
            $db->sql_query("update ".TABLE_STORIES." set catid='$newcat' where sid='$sid'");
        }
        $db->sql_query("delete from ".TABLE_STORIES_CAT." where catid='$catid'");
        echo ""._MOVEDONE."";
    }
    Max_CloseTable();
    incof();