5 # Part of the Collection Workflow Integration System (CWIS) 6 # Copyright 2002-2013 Edward Almasy and Internet Scout Research Group 7 # http://scout.wisc.edu/cwis/ 16 # ---- PUBLIC INTERFACE -------------------------------------------------- 18 # Error codes for the TOPIC 34 $this->ErrorStatus = self::OK;
35 # locate class in database 39 if ($TopicId !== NULL)
41 $this->
TopicId = intval($TopicId);
42 $DB->Query(
"SELECT * FROM Topics WHERE TopicId = ".$this->
TopicId);
45 if ($DB->NumRowsSelected() > 0)
47 # set attributes to values returned by database 48 $this->DBFields = $DB->FetchRow();
52 $this->ErrorStatus = self::NONEXISTENT;
55 elseif (func_num_args()==0)
57 # add record to database with that ID 58 $DB->Query(
"INSERT INTO Topics (TopicId) VALUES (NULL)");
59 $this->
TopicId = $DB->Query(
"SELECT LAST_INSERT_ID()" 60 .
" AS TopicId FROM Topics",
"TopicId");
64 $this->ErrorStatus = self::NONEXISTENT;
73 if ($this->ErrorStatus == self::OK)
75 # decrement the topic count for the parent forum 77 $Forum->TopicCount($Forum->TopicCount() - 1);
79 $this->DB->Query(
"Select * from Messages where ParentId = ".
80 $this->
TopicId.
" AND ParentType = 1");
82 # delete messages associated with this topic 83 while ($Entry = $this->DB->FetchRow())
85 $Message =
new Message($Entry[
"MessageId"]);
88 $this->DB->Query(
"DELETE FROM Topics WHERE TopicId=".$this->
TopicId);
105 # query for messages associated with this topic 107 SELECT * FROM Messages 108 WHERE ParentId = '".addslashes($this->
TopicId).
"' 110 ORDER BY DatePosted ASC");
112 # create Message objects from the results 113 while (FALSE !== ($Row = $this->DB->FetchRow()))
115 $Messages[$Row[
"MessageId"]] =
new Message($Row[
"MessageId"]);
127 return $this->TopicId;
137 return $CreatorName->Get(
"UserName");
147 return $CreatorName->Get(
"EMail");
158 return $this->UpdateValue(
"ForumId", $NewValue);
169 return $this->UpdateValue(
"CreatorId", $NewValue);
180 return $this->UpdateValue(
"DateCreated", $NewValue);
190 return $this->UpdateValue(
"TopicName", $NewValue);
201 return $this->UpdateValue(
"ViewCount", $NewValue);
212 return $this->UpdateValue(
"MessageCount", $NewValue);
221 return $this->ErrorStatus;
226 # ---- PRIVATE INTERFACE ------------------------------------------------- 231 private $ErrorStatus;
238 private function UpdateValue($FieldName, $NewValue)
240 if ($this->ErrorStatus == self::OK)
242 return $this->DB->UpdateValue(
"Topics", $FieldName, $NewValue,
243 "TopicId = '".$this->
TopicId.
"'", $this->DBFields, TRUE);
GetErrorStatus()
Retrieve the error status of the object.
CreatorId($NewValue=DB_NOVALUE)
Get or set the creator of this topic.
ForumId($NewValue=DB_NOVALUE)
Set or modify the forum with which this topic is associated.
Abstraction for forum messages and resource comments.
A converastion forum which includes topics and messages.
SQL database abstraction object with smart query caching.
CreatorEmail()
Get the e-mail address of the user who created this topic.
CreatorName()
Get the CWIS name of the user who created this topic.
Abstraction for topics within a Forum.
TopicName($NewValue=DB_NOVALUE)
Get or modify the name of this topic.
DateCreated($NewValue=DB_NOVALUE)
Get or set the creation date of this topic.
Delete()
Remove this topic from the database, deleting the underlying messages.
ViewCount($NewValue=DB_NOVALUE)
Get or set the view count for this topic.
TopicId()
Get the ID of this topic.
GetMessageList()
Get the list of messages in this topic.
MessageCount($NewValue=DB_NOVALUE)
Get or set the message count for this topic.
CWIS-specific user class.
__construct($TopicId=NULL)
Object Constructor.