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 forum object
37 # locate class in database
41 if ($ForumId !== NULL)
43 $this->
ForumId = intval($ForumId);
44 $DB->Query(
"SELECT * FROM Forums WHERE ForumId = "
48 if ($DB->NumRowsSelected() > 0)
50 # set attributes to values returned by database
51 $this->DBFields = $DB->FetchRow();
58 elseif (func_num_args()==0)
60 # add record to database with that ID
61 $DB->Query(
"INSERT INTO Forums (ForumId) VALUES (NULL)");
62 $this->
ForumId = $DB->Query(
"SELECT LAST_INSERT_ID() AS ForumId"
63 .
" FROM Forums",
"ForumId");
79 $this->DB->Query(
"Select * from Topics where ForumId = ".
80 $this->
ForumId.
" ORDER BY DateCreated Desc");
82 # get list of topics for this forum
83 while ($Entry = $this->DB->FetchRow())
85 $Topic =
new Topic($Entry[
"TopicId"]);
88 # delete record from database
89 $this->DB->Query(
"DELETE FROM Forums WHERE ForumId = ".$this->
ForumId);
112 return $Message->DatePosted().
" by ";
125 return $Message->PosterName();
136 return $Message->PosterEmail();
146 return $ModeratorName->Get(
"UserName");
156 return $ModeratorName->Get(
"EMail");
167 $this->DB->Query(
"Select * from Topics where ForumId = ".
168 $this->
ForumId.
" ORDER BY DateCreated Desc");
170 # get list of topics for this forum
171 while ($Entry = $this->DB->FetchRow())
173 $Topics[$Entry[
"TopicId"]] =
new Topic($Entry[
"TopicId"]);
188 SELECT M.* FROM Messages M
190 ON M.ParentId = T.TopicId
192 AND T.ForumId = '".addslashes($this->
ForumId).
"'
193 ORDER BY DatePosted DESC
196 if ($this->DB->NumRowsSelected())
198 $Row = $this->DB->FetchRow();
199 $Message =
new Message($Row[
"MessageId"]);
249 function AddTopic($Author, $TopicName, $Subject, $Body)
251 $Topic =
new Topic();
253 $Topic->TopicName($TopicName);
254 $Topic->DateCreated(date(
"YmdHis"));
255 $Topic->ForumId($this->
ForumId);
256 $Topic->ViewCount(
"0");
257 $Topic->MessageCount(
"0");
258 $Topic->CreatorId($Author->Id() );
262 $this->
PostMessage($Topic->TopicId(), $Author, $Subject, $Body);
264 return $Topic->TopicId();
269 $Topic =
new Topic($TopicId);
270 if ($Topic->GetErrorStatus() ==
Topic::OK)
272 # If the selected topic and forum exist
274 $Message->ParentId( $TopicId );
276 $Message->DatePosted(date(
"YmdHis"));
277 $Message->PosterId( $Author->Id() );
278 $Message->Subject( $Subject );
279 $Message->Body( $Body );
281 # update counts for topic and forum
284 $Topic->MessageCount($Topic->MessageCount() + 1);
302 $Message =
new Message($MessageId);
306 $TopicId = $Message->ParentId();
307 $Topic =
new Topic($TopicId);
308 if ($Topic->GetErrorStatus() ==
Topic::OK)
310 $ForumId = $Topic->ForumId();
311 $Forum =
new Forum($ForumId);
312 if ($Forum->GetErrorStatus() == self::OK)
314 # update count for topic and forum and delete message
315 $Topic->MessageCount($Topic->MessageCount() - 1 );
316 $Forum->MessageCount($Forum->MessageCount() - 1 );
324 return self::NONEXISTENT;
329 return self::NOSUCHTOPIC;
334 return self::NOSUCHMESSAGE;
338 # ---- PRIVATE INTERFACE -------------------------------------------------
343 private $ErrorStatus;
350 private function UpdateValue($FieldName, $NewValue)
354 return $this->DB->UpdateValue(
"Forums", $FieldName, $NewValue,
355 "ForumId = '".$this->
ForumId.
"'", $this->DBFields, TRUE);
AddTopic($Author, $TopicName, $Subject, $Body)
Abstraction for forum messages and resource comments.
MessageCount($NewValue=DB_NOVALUE)
Get or set the forum's message count.
A converastion forum which includes topics and messages.
SQL database abstraction object with smart query caching.
LastMessageDate()
Get the date of the most recent post to the forum.
GetErrorStatus()
Retrieve error codes associated with the creation of the forum.
ModeratorEmail()
Get the e-mail address of the forum's moderator.
ForumDescription($NewValue=DB_NOVALUE)
Get or modify the forum description.
Abstraction for topics within a Forum.
TopicCount($NewValue=DB_NOVALUE)
Get or set the forum's topic count.
LastMessagePosterEmail()
Get the e-mail address of the user with the most recent post.
GetLastMessage()
Get the last message posted in the forum.
Forum($ForumId=NULL)
Object Constructor.
PostMessage($TopicId, $Author, $Subject, $Body)
static DeleteMessage($MessageId)
Delete a message from a forum, updating the message counts for the associated forum and topic...
ForumId()
Get the forum's ID.
ModeratorId($NewValue=DB_NOVALUE)
Get or set the forum's moderator.
Delete()
Remove this forum, deleting all assocated topics and messages.
GetTopicList()
Get the list of the topics in this forum.
ForumName($NewValue=DB_NOVALUE)
Get or modify the forum's name.
ModeratorName()
Get the CWIS username of the forum's moderator.
LastMessagePoster()
Get the CWIS username of the user with the most recent post.
CWIS-specific user class.