<?php


// contents of function ShowLinks

/*

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 $bbsubject_id, $foruminfo, $THIS_PAGE, $control, $page;
  
//  ShowArray ("foruminfo", $foruminfo);

  echo "<p>\n";
  
  if ($subjectrow ['admin_only'] && !($foruminfo ['admin'] ||
      $foruminfo ['moderator_topic'] == $subjectrow ['bbtopic_id'] ||
      $foruminfo ['moderator_section'] == $subjectrow ['bbsection_id'])) 
    echo "<p><b>Postings by administrators only.</b></p>\n";
  else if (!$control ['allow_posts'])
    echo "<p><b>Posting of new messages is disabled at present.</b></p>\n";
  else
    {
    if ($subjectrow ['closed'] && !($foruminfo ['admin'] ||
      $foruminfo ['moderator_topic'] == $subjectrow ['bbtopic_id'] ||
      $foruminfo ['moderator_section'] == $subjectrow ['bbsection_id'])) 
      echo "<b>This subject is now closed.</b>&nbsp;&nbsp;\n";
    else if ($action != 'add')
      {
      hLink ("\n<img src=\"/images/reply_to_subject.gif\" border=0 width=15 height=15 alt=\"[Reply to this subject]\">\n"
           . "&nbsp;Reply to this subject", 
             $THIS_PAGE, 
             sprintf ("action=add&bbsubject_id=%d&page=%d", $bbsubject_id, $page));
      echo "&nbsp;&nbsp;";
      if ($subjectrow ['closed'])
        echo ("<b>(closed)</b>&nbsp;&nbsp;");
      }
    hLink ("<img src=\"/images/new_subject.gif\" border=0 width=15 height=15 alt=\"[New subject]\">\n"
         . "&nbsp;Start a new subject", 
           $THIS_PAGE, 
           sprintf ("action=add&bbtopic_id=%d", $subjectrow ['bbtopic_id']));
    if ($subjectrow ['admin_only'])
      echo ("&nbsp;&nbsp;<b>(admin only)</b>");

    echo "&nbsp;&nbsp";
    
    } // end of reply possible   

  // make page number look reasonable :)
  if (!$page)
    $page = 1;

  // show "refresh page" link - we always want to do this 
      
  hLink ("<img src=\"/images/refresh.gif\" alt=\"[Refresh]\" width=13 height=16 border=0>"
       . "&nbsp;Refresh page", 
         $THIS_PAGE, "bbsubject_id=$bbsubject_id&page=$page");
    
  echo "</p>";

?>
