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 17 # ---- PUBLIC INTERFACE -------------------------------------------------- 37 $this->ErrorStatus = self::NONEXISTENT;
41 if (is_null($MessageId))
43 # add record to database with that ID 44 $this->DB->Query(
"INSERT INTO Messages (MessageId) VALUES (NULL)");
45 $this->DB->Query(
"SELECT LAST_INSERT_ID() AS Id FROM Messages");
47 if ($this->DB->NumRowsSelected())
49 $this->
MessageId = intval($this->DB->FetchField(
"Id"));
50 $this->ErrorStatus = self::OK;
58 SELECT * FROM Messages 59 WHERE MessageId = '".intval($MessageId).
"'");
61 if ($this->DB->NumRowsSelected())
63 # set attributes to values returned by database 64 $this->DBFields = $this->DB->FetchRow();
65 $this->
MessageId = intval($this->DBFields[
"MessageId"]);
66 $this->ErrorStatus = self::OK;
76 if ($this->ErrorStatus == self::OK)
78 $this->DB->Query(
"DELETE FROM Messages WHERE MessageId = ".$this->
MessageId);
93 return $this->MessageId;
103 return $PosterName->Get(
"UserName");
113 return $PosterName->Get(
"EMail");
123 return $this->UpdateValue(
"EditorId", $NewValue);
135 return $this->UpdateValue(
"ParentId", $NewValue);
147 return $this->UpdateValue(
"ParentType", $NewValue);
157 return $this->UpdateValue(
"DatePosted", $NewValue);
167 return $this->UpdateValue(
"DateEdited", $NewValue);
177 return $this->UpdateValue(
"PosterId", $NewValue);
187 return $this->UpdateValue(
"Subject", $NewValue);
197 return $this->UpdateValue(
"Body", $NewValue);
206 return $this->ErrorStatus;
211 # ---- PRIVATE INTERFACE ------------------------------------------------- 216 private $ErrorStatus;
225 private function UpdateValue($FieldName, $NewValue)
227 if ($this->ErrorStatus == self::OK)
229 return $this->DB->UpdateValue(
230 "Messages", $FieldName, $NewValue,
231 "MessageId = '".$this->
MessageId.
"'", $this->DBFields, TRUE);
DateEdited($NewValue=DB_NOVALUE)
Get or set the date the message was last edited.
MessageId()
Get this message's messageId.
Abstraction for forum messages and resource comments.
GetErrorStatus()
Retrieve the error status.
SQL database abstraction object with smart query caching.
const PARENTTYPE_RESOURCE
Subject($NewValue=DB_NOVALUE)
Get or set the message subject.
PosterEmail()
Get the email address of the most recent poster.
__construct($MessageId=NULL)
Object constructor.
Body($NewValue=DB_NOVALUE)
Get or set the message body.
PosterName()
Get the CWIS username of the most recent poster.
EditorId($NewValue=DB_NOVALUE)
Get the CWIS user ID of the most recent editor.
DatePosted($NewValue=DB_NOVALUE)
Get or set the date posted.
Delete()
Delete this message from the underlying database.
ParentId($NewValue=DB_NOVALUE)
Get or set the ParentId.
CWIS-specific user class.
PosterId($NewValue=DB_NOVALUE)
Get or set the poster id (e.g., the author) for this message.
ParentType($NewValue=DB_NOVALUE)
Get or set the ParentType.