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
32 function Topic($TopicId = NULL )
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();
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");
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"]);
134 return $CreatorName->Get(
"UserName");
144 return $CreatorName->Get(
"EMail");
202 # ---- PRIVATE INTERFACE -------------------------------------------------
207 private $ErrorStatus;
214 private function UpdateValue($FieldName, $NewValue)
218 return $this->DB->UpdateValue(
"Topics", $FieldName, $NewValue,
219 "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.
Topic($TopicId=NULL)
Object Constructor.
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.