1: <?php
2: /**
3: *Comment Class
4: * @package classes
5: */
6:
7: // force UTF-8 Ø
8:
9: class Comment extends PersistentObject {
10:
11: var $comment_error_text = NULL;
12:
13: /**
14: * This is a simple class so that we have a convienient "handle" for manipulating comments.
15: *
16: * @return Comment
17: */
18:
19: /**
20: * Constructor for a comment
21: *
22: * @param int $id set to the ID of the comment if not a new one.
23: * @return Comment
24: */
25: function __construct($id=NULL) {
26: $new = $this->instantiate('comments', array('id'=>$id), 'id', true, is_null($id));
27: }
28:
29: /**
30: * Sets up default items on new comment objects
31: *
32: */
33: function setDefaults() {
34: $this->set('date', date('Y-m-d H:i:s'));
35: }
36:
37: // convienence get & set functions
38:
39: /**
40: * returns the comment date/time
41: *
42: * @return string
43: */
44: function getDateTime() { return $this->get('date'); }
45: /**
46: * Sets a comment date/time value
47: *
48: * @param string $datetime
49: */
50: function setDateTime($datetime) {
51: if ($datetime == "") {
52: $this->set('date', '0000-00-00 00:00:00');
53: } else {
54: $newtime = dateTimeConvert($datetime);
55: if ($newtime === false) return;
56: $this->set('date', $newtime);
57: }
58: }
59:
60: /**
61: * Returns the id of the comment owner
62: *
63: * @return int
64: */
65: function getOwnerID() { return $this->get('ownerid'); }
66: /**
67: * Sets the id of the owner of the comment
68: *
69: * @param int $value
70: */
71: function setOwnerID($value) { $this->set('ownerid', $value); }
72:
73: /**
74: * Returns the commentor's name
75: *
76: * @return string
77: */
78: function getName() { return $this->get('name'); }
79: /**
80: * Sets the commentor's name
81: *
82: * @param string $value
83: */
84: function setName($value) { $this->set('name', $value); }
85:
86: /**
87: * returns the email address of the commentor
88: *
89: * @return string
90: */
91: function getEmail() { return $this->get('email'); }
92: /**
93: * Sets the email address of the commentor
94: *
95: * @param string $value
96: */
97: function setEmail($value) { $this->set('email', $value); }
98:
99: /**
100: * returns the Website of the commentor
101: *
102: * @return string
103: */
104: function getWebsite() { return $this->get('website'); }
105: /**
106: * Stores the website of the commentor
107: *
108: * @param string $value
109: */
110: function setWebsite($value) { $this->set('website', $value); }
111:
112: /**
113: * Returns the comment text
114: *
115: * @return string
116: */
117: function getComment() { return $this->get('comment'); }
118: /**
119: * Stores the comment text
120: *
121: * @param string $value
122: */
123: function setComment($value) { $this->set('comment', $value); }
124:
125: /**
126: * Returns true if the comment is marked for moderation
127: *
128: * @return int
129: */
130: function getInModeration() { return $this->get('inmoderation'); }
131: /**
132: * Sets the moderation flag of the comment
133: *
134: * @param int $value
135: */
136: function setInModeration($value) { $this->set('inmoderation', $value); }
137:
138: /**
139: * Returns the 'type' of the comment. i.e. the class of the owner object
140: *
141: * @return string
142: */
143: function getType() {
144: return $this->get('type');
145: }
146: /**
147: * Sets the 'type' field of the comment
148: *
149: * @param string $type
150: */
151: function setType($type) {
152: $this->set('type', $type);
153: }
154:
155: /**
156: * Returns the IP address of the comment poster
157: *
158: * @return string
159: */
160: function getIP() { return $this->get('ip'); }
161: /**
162: * Sets the IP address field of the comment
163: *
164: * @param string $value
165: */
166: function setIP($value) { $this->set('ip', $value); }
167:
168: /**
169: * Returns true if the comment is flagged private
170: *
171: * @return bool
172: */
173: function getPrivate() { return $this->get('private'); }
174: /**
175: * Sets the private flag of the comment
176: *
177: * @param bool $value
178: */
179: function setPrivate($value) { $this->set('private', $value); }
180:
181: /**
182: * Returns true if the comment is flagged anonymous
183: *
184: * @return bool
185: */
186: function getAnon() { return $this->get('anon'); }
187: /**
188: * Sets the anonymous flag of the comment
189: *
190: * @param bool $value
191: */
192: function setAnon($value) { $this->set('anon', $value); }
193:
194: /**
195: * Returns the custom data field of the comment
196: *
197: * @return string
198: */
199: function getCustomData() { return $this->get('custom_data'); }
200: /**
201: * Stores the custom data field of the comment
202: *
203: * @param string $value
204: */
205: function setCustomData($value) { $this->set('custom_data', $value); }
206: }
207: ?>
208: