<?php

  $tid = intval($_REQUEST["tid"]);
  include ("$www_dir/classes/topics.class.php");
  $SBBTopics = new SBBTopics();
  $SBBTopics->tid = $tid;
  $SBBTopics->GetPosts(); 

  if ($SBBTopics->posts["main"] && array_key_exists($SBBTopics->posts["main"]->fid,$forum)) {

    $row = $SBBTopics->posts["main"];
    
    $FORM_HEADLINE = $DESCR_SUBMIT = lang("move_topic");
    $MOVE_TOPIC_INFO1 = lang("move_topic_info1");
    $MOVE_TOPIC_INFO2 = lang("move_topic_info2");
    $DESCR_TOPIC = lang("topic");
    $TOPIC_ID = $tid;

    $TOPIC_LINK = ($board_config->seo ? "$main_path/sbbt" . $tid . adddescr2link($row->topic) . ".html" : "$main_script?todo=viewtopic&amp;tid=$tid");
    $TOPIC_TITLE = $row->topic;

    //Forums
    for ($i=0;$i<count($forums);$i++) {
      $forumsPerCat[$forums[$i]->cat_id] .= "<option value='" . $forums[$i]->id . "' " . ($row->fid == $forums[$i]->id ? "disabled='disabled'" : "") . ">" . $forums[$i]->title . "</option>\n";
      if ($forums[$i]->cat_id) $hasCategories = true;
    }
    if ($hasCategories) {
      if ($forumsPerCat[0]) {
        $FORUM_OPTIONS = "<optgroup label='" . lang("no_category") . "'>\n" . $forumsPerCat[0] . "</optgroup>\n";
      }
      for ($i=0;$i<count($categories);$i++) {
        if ($forumsPerCat[$categories[$i]->id]) {
           $FORUM_OPTIONS .= "<optgroup label='" . he($categories[$i]->title) . "'>\n" . $forumsPerCat[$categories[$i]->id] . "</optgroup>\n";
        }
      }
    } else {
      $FORUM_OPTIONS = implode("",$forumsPerCat);
    }

    /************
     * initiate template and assign variables
     ************/   
    $movetopicVARS = array('MOVE_TOPIC_INFO1' => $MOVE_TOPIC_INFO1,
                          'MOVE_TOPIC_INFO2' => $MOVE_TOPIC_INFO2,
                          'FORM_HEADLINE' => $FORM_HEADLINE,
                          'DESCR_TOPIC' => $DESCR_TOPIC,
                          'TOPIC_TITLE' => $TOPIC_TITLE,
                          'FORUM_OPTIONS' => $FORUM_OPTIONS,
                          'TOPIC_ID' => $TOPIC_ID,
                          'DESCR_SUBMIT' => $DESCR_SUBMIT,

                          'CONF' => $GLOBAL_TEMPLATE_VARS,
                          'FLAGS' => $TEMPLATE_FLAGS
                          );
      
    $QuickSkin = new QuickSkin("move_topic.html");
    $QuickSkin->assign($movetopicVARS);
    $content .= $QuickSkin->result();
    unset($QuickSkin);

  } else {
    /************
     * initiate template and assign variables
     ************/         
    $QuickSkin = new QuickSkin("status_messages.html");
    $QuickSkin->assign("INFO",lang("topic_doesnt_exist"));
    $content .= $QuickSkin->result();
    unset($QuickSkin);
  }
  
  
?>