sBody = $sNewBody; $this->sSubject = $sNewSubject; $this->iUserID = $iNewUserID; $this->iThreadID = $iNewThreadID; $this->dDate = null; // This will get added in the SQL statement $this->iInReplyTo = $iNewInReplyTo; $this->iId = -1; // This will get created when the entry SQL statement } /** * Return the CommentID */ function getID(){ return $this->iId; } /** * Return the ThreadID for the Comment */ function getThreadID(){ return $this->iThreadID; } /** * Set a new Thread ID */ function setThreadID($iNewThreadID){ $this->iThreadID = $iNewThreadID; } /** * Return the UserID */ function getUserID(){ return $this->iUserID; } /* * Set a new User ID */ function setUserID($iNewUserID){ $this->iUserID = $iNewUserID; } /** * Return the Subject text */ function getSubject(){ return $this->sSubject; } /** * Set a new Subject text */ function setSubject($sNewSubject){ $this->sSubject = $sNewSubject; } /** * Return the Text Body */ function getBody(){ return $this->sBody; } /** * Set a new TextBody */ function setBody($sNewBody){ $this->sBody = $sNewBody; } /** * Get a Date Created */ function getDate(){ return $this->dDate; } /** * Return the comment this is a reply to */ function getInReplyTo(){ return $this->iInReplyTo; } /** * Sets the comment this is a reply to */ function setInReplyTo($sNewCommentID){ $this->iInReplyTo = $sNewCommentID; } /** * Static function. * Given a web_documents primary key it will create a * discusson comment object and populate it with the * corresponding database values * * @return Comment populated Comment object on successful query, false otherwise and set $_SESSION["errorMessage"] */ function & get($iNewCommentID) { global $default; $sql = $default->db; $result = $sql->query(array("SELECT * FROM $default->discussion_comments_table WHERE id = ?", $iNewCommentID));/*ok*/ if ($result) { if ($sql->next_record()) { $oDiscussionComment = & new DiscussionComment($sql->f("body"),$sql->f("subject"),$sql->f("user_id"),$sql->f("thread_id"),$sql->f("in_reply_to")); $oDiscussionComment->iId = $iNewCommentID; $oDiscussionComment->dDate = $sql->f("date"); return $oDiscussionComment; } return false; } return false; } /** * Static function * Get a list of DiscussionComments * * @param String Where clause (optional) * * @return Array array of DiscussionComments objects, false otherwise */ function getList($sWhereClause = null) { global $default; $aDiscussionComments = array(); $sql = $default->db; $result = $sql->query("SELECT * FROM " . $default->discussion_comments_table . (isset($sWhereClause) ? " WHERE " . $sWhereClause : ""));/*wc*/ if ($result) { while ($sql->next_record()) { $aDiscussionComments[] = & DiscussionComment::get($sql->f("id")); } return $aDiscussionComments; } return false; } function _fieldValues () { return array( 'thread_id' => $this->iThreadID, 'user_id' => $this->iUserID, 'subject' => $this->sSubject, 'body' => $this->sBody, 'date' => getCurrentDate(), 'in_reply_to' => $this->iInReplyTo, ); } function _table () { return $default->discussion_comments_table; } function delete(){ global $default; // only delete the object if it exists in the database if ($this->iId > 0) { //check to see if group is linked to a unit $sql = $default->db; $query = array("SELECT * FROM ". $default->discussion_comments_table . " WHERE id = ?", $this->iId);/*ok*/ $sql->query($query); $rows = $sql->num_rows($sql); if ($rows > 1) { // duplicate Thread exists return false; } else { $sql = $default->db; $result = $sql->query("DELETE FROM $default->discussion_comments_table WHERE id = $this->iId"); if ($result) { return true; } return false; } } return false; } } ?>