<?php


// contents of function ConfirmDelete

/*

Copyright © 2001 Nick Gammon.

  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, 
  or (at your option) any later version. 

  This program is distributed in the hope that it will be useful, 
  but WITHOUT ANY WARRANTY; without even the implied warranty of 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
  See the GNU General Public License for more details. 

*/

  global $bbpost_id, $bbtopic_id, $foruminfo, $control, $THIS_PAGE, $page;
    
  if (!$bbpost_id)
    Problem ("No message ID specified");

  if (!$control ['allow_deletes'])
    Problem ("Deleting of messages is not permitted at present");
    
  $query = "SELECT * FROM bbpost, bbsubject, bbtopic "
         . "WHERE bbpost_id = $bbpost_id "
         . "  AND   bbsubject.bbsubject_id = bbpost.bbsubject_id "
         . "  AND   bbtopic.bbtopic_id = bbsubject.bbtopic_id ";
    
//  echo $query;
                        
  $result = mysql_query ($query) 
      or Problem ("Select of message failed: " . mysql_error ());
    
  if (!($row = mysql_fetch_array ($result)))
    Problem ("Message $bbpost_id is not on file");
  
  if ($row ['bbuser_id'] != $foruminfo ['bbuser_id'] && 
                    !($foruminfo ['admin'] ||
                     $foruminfo ['moderator_topic'] == $row ['bbtopic_id'] ||
                     $foruminfo ['moderator_section'] == $row ['bbsection_id']))
    Problem ("You did not post this message");
    
  $message = $row ['post_text'];
    
  // now convert to html    
  if (!$row ['html'])
    $message =  nl2br (htmlentities ($message));
 
  // now do "forum code"     
  if ($row ['forum_code'])
    TranslateForumCode ($message);
 
  $table = array 
    (
    'Subject' => $row ['subject_name'],
    'Date' => $row ['post_date'],   
    'Message' => $message,
    );  // end of array

  echo "<form METHOD=post ACTION=\"$THIS_PAGE\">\n";

  echo "<hr><h3>Confirm delete of this message ...</h3>\n";
  
  ShowTable ($table,  // the data
            array (     // table parameters
                  'table' => 'border=0 cellpadding=5 width="100%"',
                  'LH' => 'valign=top bgcolor="#ADD8E6" align=right width="10%"',
                  'RH' => 'bgcolor="#FAF0E6" align=left'
                  ),
            array (     // specials
                  'Date'     => array ('html' => true),  
                  'Message'     => array ('html' => true),  

                  )
            );

  mysql_free_result ($result);
?>
  <p><b>Press 'Confirm Delete' button to delete this message ...</b></p>
  <p>
  <input Type=submit Name=action Value="Confirm Delete">
  </p>

  <input type=hidden name=bbpost_id value=<?php echo ($bbpost_id); ?>>
  <input type=hidden name=bbtopic_id value=<?php echo ($bbtopic_id); ?>>
  <input type=hidden name=page value=<?php echo ($page); ?>>
  <input type=hidden name=action value="Confirm Delete">
  <?php FormSession (); ?>
  
  </form>
  
<?php
    

?>
