6 # Topic->Topic($TopicId)
11 # Topic->DateCreated()
14 # Topic->MessageCount()
16 # - methods to retrieve resource attributes
18 # Copyright 2011 Internet Scout Project
19 # http://scout.wisc.edu/
29 # ---- PUBLIC INTERFACE --------------------------------------------------
32 # Error codes for the TOPIC
46 function Topic($TopicId = NULL )
49 # locate class in database
53 if ($TopicId !== NULL)
55 $this->
TopicId = intval($TopicId);
56 $DB->Query(
"SELECT * FROM Topics WHERE TopicId = ".$this->
TopicId);
59 if ($DB->NumRowsSelected() > 0)
61 # set attributes to values returned by database
62 $this->DBFields = $DB->FetchRow();
69 elseif (func_num_args()==0)
71 # add record to database with that ID
72 $DB->Query(
"INSERT INTO Topics (TopicId) VALUES (NULL)");
73 $this->
TopicId = $DB->Query(
"SELECT LAST_INSERT_ID()"
74 .
" AS TopicId FROM Topics",
"TopicId");
89 # decrement the topic count for the parent forum
91 $Forum->TopicCount($Forum->TopicCount() - 1);
93 $this->DB->Query(
"Select * from Messages where ParentId = ".
94 $this->
TopicId.
" AND ParentType = 1");
96 # delete messages associated with this topic
97 while ($Entry = $this->DB->FetchRow())
99 $Message =
new Message($Entry[
"MessageId"]);
102 $this->DB->Query(
"DELETE FROM Topics WHERE TopicId=".$this->
TopicId);
119 $this->DB->Query(
"Select * from Messages where ParentId = ".
121 " AND ParentType = 1 ORDER BY DatePosted DESC");
123 # delete messages associated with this topic
124 while ($Entry = $this->DB->FetchRow())
126 $Messages[$Entry[
"MessageId"]] =
new Message($Entry[
"MessageId"]);
145 return $CreatorName->Get(
"UserName");
155 return $CreatorName->Get(
"EMail");
208 # ---- PRIVATE INTERFACE -------------------------------------------------
213 private $ErrorStatus;
215 # convenience function to supply parameters to Database->UpdateValue()
216 private function UpdateValue($FieldName, $NewValue)
220 return $this->DB->UpdateValue(
"Topics", $FieldName, $NewValue,
221 "TopicId = '".$this->
TopicId.
"'", $this->DBFields, TRUE);