CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

Message.php
Go to the documentation of this file.
1 <?PHP
2 #
3 # FILE: Message.php
4 #
5 # Part of the Collection Workflow Integration System (CWIS)
6 # Copyright 2012-2013 Edward Almasy and Internet Scout Research Group
7 # http://scout.wisc.edu/cwis
8 #
9
14 class Message extends Item
15 {
16 const PARENTTYPE_TOPIC = 1;
17 const PARENTTYPE_RESOURCE = 2;
18
19 # ---- PUBLIC INTERFACE --------------------------------------------------
20
23
28 public static function Create()
29 {
30 $DB = new Database();
31
32 # create a new empty message record
33 $DB->Query("INSERT INTO Messages (MessageId) VALUES (NULL)");
34
35 # get its message id
36 $MessageId = $DB->LastInsertId();
37
38 $Message = new Message($MessageId);
39 return $Message;
40 }
41
45 public function Delete()
46 {
47 $this->Destroy();
48 }
49
54
59 public function MessageId()
60 {
61 return $this->Id();
62 }
63
68 public function PosterName()
69 {
70 $PosterId = (int)$this->PosterId();
71 if ((new CWUserFactory())->UserExists($PosterId))
72 {
73 $PosterName = new CWUser($PosterId);
74 return $PosterName->Get("UserName");
75 }
76 else
77 {
78 return NULL;
79 }
80 }
81
86 public function PosterEmail()
87 {
88 $PosterId = (int)$this->PosterId();
89 if ((new CWUserFactory())->UserExists($PosterId))
90 {
91 $PosterName = new CWUser($PosterId);
92 return $PosterName->Get("EMail");
93 }
94 else
95 {
96 return NULL;
97 }
98 }
99
105 public function EditorId($NewValue = DB_NOVALUE)
106 {
107 return $this->UpdateValue("EditorId", $NewValue);
108 }
109
117 public function ParentId($NewValue = DB_NOVALUE)
118 {
119 return $this->UpdateValue("ParentId", $NewValue);
120 }
121
129 public function ParentType($NewValue = DB_NOVALUE)
130 {
131 return $this->UpdateValue("ParentType", $NewValue);
132 }
133
139 public function DatePosted($NewValue = DB_NOVALUE)
140 {
141 return $this->UpdateValue("DatePosted", $NewValue);
142 }
143
149 public function DateEdited($NewValue = DB_NOVALUE)
150 {
151 return $this->UpdateValue("DateEdited", $NewValue);
152 }
153
159 public function PosterId($NewValue = DB_NOVALUE)
160 {
161 return $this->UpdateValue("PosterId", $NewValue);
162 }
163
169 public function Subject($NewValue = DB_NOVALUE)
170 {
171 return $this->UpdateValue("Subject", $NewValue);
172 }
173
179 public function Body($NewValue = DB_NOVALUE)
180 {
181 return $this->UpdateValue("Body", $NewValue);
182 }
184 }
Message\DateEdited
DateEdited($NewValue=DB_NOVALUE)
Get or set the date the message was last edited.
Definition: Message.php:149
Item\Id
Id()
Get item ID.
Definition: Item.php:81
Message\MessageId
MessageId()
Get this message&#39;s messageId.
Definition: Message.php:59
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:284
Message\Create
static Create()
Create an empty message object.
Definition: Message.php:28
Database
SQL database abstraction object with smart query caching.
Definition: Database.php:22
Message\PARENTTYPE_TOPIC
const PARENTTYPE_TOPIC
Definition: Message.php:16
Message\PARENTTYPE_RESOURCE
const PARENTTYPE_RESOURCE
Definition: Message.php:17
Item\$DB
$DB
Definition: Item.php:210
Message\Subject
Subject($NewValue=DB_NOVALUE)
Get or set the message subject.
Definition: Message.php:169
Message\PosterEmail
PosterEmail()
Get the email address of the most recent poster.
Definition: Message.php:86
Item\Destroy
Destroy()
Destroy item.
Definition: Item.php:60
CWUserFactory
CWIS-specific user factory class.
Definition: CWUserFactory.php:13
Message\Body
Body($NewValue=DB_NOVALUE)
Get or set the message body.
Definition: Message.php:179
PHP
PHP
Definition: RSSClient--Test.php:12
Message\PosterName
PosterName()
Get the CWIS username of the most recent poster.
Definition: Message.php:68
Item
Common base class for persistent items store in database.
Definition: Item.php:13
DB_NOVALUE
const DB_NOVALUE
Definition: Database.php:1738
Message\EditorId
EditorId($NewValue=DB_NOVALUE)
Get the CWIS user ID of the most recent editor.
Definition: Message.php:105
Message\DatePosted
DatePosted($NewValue=DB_NOVALUE)
Get or set the date posted.
Definition: Message.php:139
Message\Delete
Delete()
Delete this message from the underlying database.
Definition: Message.php:45
Message\ParentId
ParentId($NewValue=DB_NOVALUE)
Get or set the ParentId.
Definition: Message.php:117
CWUser
CWIS-specific user class.
Definition: CWUser.php:13
Message\PosterId
PosterId($NewValue=DB_NOVALUE)
Get or set the poster id (e.g., the author) for this message.
Definition: Message.php:159
Message\ParentType
ParentType($NewValue=DB_NOVALUE)
Get or set the ParentType.
Definition: Message.php:129