CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

Topic.php
Go to the documentation of this file.
1 <?PHP
2 #
3 # FILE: Topic.php
4 #
5 # Part of the Collection Workflow Integration System (CWIS)
6 # Copyright 2002-2016 Edward Almasy and Internet Scout Research Group
7 # http://scout.wisc.edu/cwis/
8 #
9
14 class Topic extends Item
15 {
16 # ---- PUBLIC INTERFACE --------------------------------------------------
17
20
25 public static function Create()
26 {
27 $DB = new Database();
28
29 # create a new topic
30 $DB->Query("INSERT INTO Topics (TopicId) VALUES (NULL)");
31
32 # get its topic id
33 $TopicId = $DB->LastInsertId();
34
35 # set parameters
36 $Topic = new Topic($TopicId);
37 return $Topic;
38 }
39
43 public function Delete()
44 {
45 # decrement the topic count for the parent forum
46 $Forum = new Forum($this->ForumId());
47 $Forum->TopicCount($Forum->TopicCount() - 1);
48
49 $this->DB->Query("SELECT * FROM Messages WHERE ParentId = ".
50 $this->Id()." AND ParentType = 1");
51
52 # delete messages associated with this topic
53 while ($Entry = $this->DB->FetchRow())
54 {
55 $Message = new Message($Entry["MessageId"]);
56 $Message->Delete();
57 }
58
59 # delete this topic itself
60 $this->Destroy();
61 }
62
67
72 public function GetMessageList()
73 {
74 $Messages = array();
75
76 # query for messages associated with this topic
77 $this->DB->Query("
78 SELECT * FROM Messages
79 WHERE ParentId = '".addslashes($this->Id())."'
80 AND ParentType = '1'
81 ORDER BY DatePosted ASC");
82
83 # create Message objects from the results
84 while (FALSE !== ($Row = $this->DB->FetchRow()))
85 {
86 $Messages[$Row["MessageId"]] = new Message($Row["MessageId"]);
87 }
88
89 return $Messages;
90 }
91
97 public function TopicId()
98 {
99 return $this->Id();
100 }
101
106 public function CreatorName()
107 {
108 $CreatorName = new CWUser((int)$this->CreatorId());
109 return $CreatorName->Get("UserName");
110 }
111
116 public function CreatorEmail()
117 {
118 $CreatorName = new CWUser((int)$this->CreatorId());
119 return $CreatorName->Get("EMail");
120 }
121
128 public function ForumId($NewValue = DB_NOVALUE)
129 {
130 return $this->UpdateValue("ForumId", $NewValue);
131 }
132
139 public function CreatorId($NewValue = DB_NOVALUE)
140 {
141 return $this->UpdateValue("CreatorId", $NewValue);
142 }
143
150 public function DateCreated($NewValue = DB_NOVALUE)
151 {
152 return $this->UpdateValue("DateCreated", $NewValue);
153 }
154
160 public function TopicName($NewValue = DB_NOVALUE)
161 {
162 return $this->UpdateValue("TopicName", $NewValue);
163 }
164
171 public function ViewCount($NewValue = DB_NOVALUE)
172 {
173 return $this->UpdateValue("ViewCount", $NewValue);
174 }
175
182 public function MessageCount($NewValue = DB_NOVALUE)
183 {
184 return $this->UpdateValue("MessageCount", $NewValue);
185 }
186
188 }
189
Topic\CreatorId
CreatorId($NewValue=DB_NOVALUE)
Get or set the creator of this topic.
Definition: Topic.php:139
Topic\ForumId
ForumId($NewValue=DB_NOVALUE)
Set or modify the forum with which this topic is associated.
Definition: Topic.php:128
Item\Id
Id()
Get item ID.
Definition: Item.php:81
Message
Abstraction for forum messages and resource comments.
Definition: Message.php:14
Item\UpdateValue
UpdateValue($ColumnName, $NewValue=DB_NOVALUE)
Convenience function to supply parameters to Database::UpdateValue().
Definition: Item.php:262
Forum
A converastion forum which includes topics and messages.
Definition: Forum.php:14
Database
SQL database abstraction object with smart query caching.
Definition: Database.php:22
Topic\CreatorEmail
CreatorEmail()
Get the e-mail address of the user who created this topic.
Definition: Topic.php:116
Item\$DB
$DB
Definition: Item.php:188
Topic\CreatorName
CreatorName()
Get the CWIS name of the user who created this topic.
Definition: Topic.php:106
Topic
Abstraction for topics within a Forum.
Definition: Topic.php:14
Item\Destroy
Destroy()
Destroy item.
Definition: Item.php:60
Topic\TopicName
TopicName($NewValue=DB_NOVALUE)
Get or modify the name of this topic.
Definition: Topic.php:160
Topic\Create
static Create()
Create an empty new topic.
Definition: Topic.php:25
PHP
PHP
Definition: RSSClient--Test.php:12
Topic\DateCreated
DateCreated($NewValue=DB_NOVALUE)
Get or set the creation date of this topic.
Definition: Topic.php:150
Topic\Delete
Delete()
Remove this topic from the database, deleting the underlying messages.
Definition: Topic.php:43
Item
Common base class for persistent items store in database.
Definition: Item.php:13
DB_NOVALUE
const DB_NOVALUE
Definition: Database.php:1706
Topic\ViewCount
ViewCount($NewValue=DB_NOVALUE)
Get or set the view count for this topic.
Definition: Topic.php:171
Topic\TopicId
TopicId()
Get the ID of this topic.
Definition: Topic.php:97
Topic\GetMessageList
GetMessageList()
Get the list of messages in this topic.
Definition: Topic.php:72
Topic\MessageCount
MessageCount($NewValue=DB_NOVALUE)
Get or set the message count for this topic.
Definition: Topic.php:182
CWUser
CWIS-specific user class.
Definition: CWUser.php:13