<?php
// Xinfeng Chen, 2002.11.07, 2002.12.16
// require_once('base_record_file.php');
// require_once('class_forum_base.php');

class CTopicList extends CBaseRecordFile {
 var $bid,$id,$_resv,$brief;

 function _explodeRecord($a_line){
  list($this->id,$this->_resv,$this->brief)=explode(SP, $a_line, 3);
 }

 function _composeRecord($a_line){
  $a_line=$this->id.SP.$this->_resv.SP.$this->brief;
 }

 function _compareRecord($a_key){
  return $a_key==$this->id;
 }

 function open($a_bid){
  $fname=CForumBase::getFilePath('TLIST',$a_bid);
  if($this->openFile($fname)){ $this->bid=$a_bid; return true; }
  else{ return false; }
 }

 function close(){
  if($this->bid!=''){$this->closeFile();}
 }

 function insertTopic($a_tid, $a_brief){
  if($this->insertNew()<=0){return false;}
  $this->id=$a_tid; $this->brief=$a_brief;
  return $this->update();
 }

 function selectTopic($a_refid, $a_tid=0){
  $this->setAbsolutePosition($a_refid);
  if(($a_tid > 0) && ($this->id != $a_tid)){
   exit('CTopicList:Record Pointer Error!');
  }
  return true;
 }

 function deleteTopic($a_refid, $a_tid){
  if($this->selectTopic($a_refid,$a_tid)){ return $this->delete(); }
  else{ return false; }
 }

 function updateTopic($a_refid, $a_tid, $a_brief){
  if($this->selectTopic($a_refid,$a_tid)){
   $this->brief=$a_brief;
   return $this->update();
  }else{
   return false;
  }
 }

}
?>