1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
<?php // $Id: comment.php,v 1.5.6.5.2.1 2005/09/20 00:35:35 skalpa Exp $ // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // // Copyright (c) 2000 XOOPS.org // // <http://www.xoops.org/> // // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // // the Free Software Foundation; either version 2 of the License, or // // (at your option) any later version. // // // // You may not change or alter any portion of this comment or credits // // of supporting developers from this source code or any supporting // // source code which is considered copyrighted (c) material of the // // original comment or credit authors. // // // // This program is distributed in the hope that it will be useful, // // but WITHOUT ANY WARRANTY; without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // // GNU General Public License for more details. // // // // You should have received a copy of the GNU General Public License // // along with this program; if not, write to the Free Software // // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // ------------------------------------------------------------------------ // // Author: Kazumi Ono (AKA onokazu) // // URL: http://www.xoops.org/ http://jp.xoops.org/ http://www.myweb.ne.jp/ // // Project: The XOOPS Project (http://www.xoops.org/) // // ------------------------------------------------------------------------- //
if (!defined('XOOPS_ROOT_PATH')) { exit(); }
/** * * * @package kernel * * @author Kazumi Ono <onokazu@xoops.org> * @copyright copyright (c) 2000-2003 XOOPS.org */
/** * A Comment * * @package kernel * * @author Kazumi Ono <onokazu@xoops.org> * @copyright copyright (c) 2000-2003 XOOPS.org */ class XoopsComment extends XoopsObject {
/** * Constructor **/ function XoopsComment() { $this->XoopsObject(); $this->initVar('com_id', XOBJ_DTYPE_INT, null, false); $this->initVar('com_pid', XOBJ_DTYPE_INT, 0, false); $this->initVar('com_modid', XOBJ_DTYPE_INT, null, false); $this->initVar('com_icon', XOBJ_DTYPE_OTHER, null, false); $this->initVar('com_title', XOBJ_DTYPE_TXTBOX, null, true, 255, true); $this->initVar('com_text', XOBJ_DTYPE_TXTAREA, null, true, null, true); $this->initVar('com_created', XOBJ_DTYPE_INT, 0, false); $this->initVar('com_modified', XOBJ_DTYPE_INT, 0, false); $this->initVar('com_uid', XOBJ_DTYPE_INT, 0, true); $this->initVar('com_ip', XOBJ_DTYPE_OTHER, null, false); $this->initVar('com_sig', XOBJ_DTYPE_INT, 0, false); $this->initVar('com_itemid', XOBJ_DTYPE_INT, 0, false); $this->initVar('com_rootid', XOBJ_DTYPE_INT, 0, false); $this->initVar('com_status', XOBJ_DTYPE_INT, 0, false); $this->initVar('com_exparams', XOBJ_DTYPE_OTHER, "", false, 255); $this->initVar('dohtml', XOBJ_DTYPE_INT, 0, false); $this->initVar('dosmiley', XOBJ_DTYPE_INT, 0, false); $this->initVar('doxcode', XOBJ_DTYPE_INT, 0, false); $this->initVar('doimage', XOBJ_DTYPE_INT, 0, false); $this->initVar('dobr', XOBJ_DTYPE_INT, 0, false); }
/** * Is this comment on the root level? * * @return bool **/ function isRoot() { return ($this->getVar('com_id') == $this->getVar('com_rootid')); } }
/** * XOOPS comment handler class. * * This class is responsible for providing data access mechanisms to the data source * of XOOPS comment class objects. * * * @package kernel * @subpackage comment * * @author Kazumi Ono <onokazu@xoops.org> * @copyright copyright (c) 2000-2003 XOOPS.org */ class XoopsCommentHandler extends XoopsPersistableObjectHandler { function XoopsCommentHandler(&$db) { $this->XoopsPersistableObjectHandler($db, 'xoopscomments', 'XoopsComment', 'com_id', 'com_title'); }
/** * Retrieves comments for an item * * @param int $module_id Module ID * @param int $item_id Item ID * @param string $order Sort order * @param int $status Status of the comment * @param int $limit Max num of comments to retrieve * @param int $start Start offset * * @return array Array of {@link XoopsComment} objects **/ function getByItemId($module_id, $item_id, $order = null, $status = null, $limit = null, $start = 0) { $criteria = new CriteriaCompo(new Criteria('com_modid', intval($module_id))); $criteria->add(new Criteria('com_itemid', intval($item_id))); if (isset($status)) { $criteria->add(new Criteria('com_status', intval($status))); } if (isset($order)) { $criteria->setSort("com_created"); $criteria->setOrder($order); } if (isset($limit)) { $criteria->setLimit($limit); $criteria->setStart($start); } return $this->getObjects($criteria); }
/** * Gets total number of comments for an item * * @param int $module_id Module ID * @param int $item_id Item ID * @param int $status Status of the comment * * @return array Array of {@link XoopsComment} objects **/ function getCountByItemId($module_id, $item_id, $status = null) { $criteria = new CriteriaCompo(new Criteria('com_modid', intval($module_id))); $criteria->add(new Criteria('com_itemid', intval($item_id))); if (isset($status)) { $criteria->add(new Criteria('com_status', intval($status))); } return $this->getCount($criteria); }
/** * Get the top {@link XoopsComment}s * * @param int $module_id * @param int $item_id * @param strint $order * @param int $status * * @return array Array of {@link XoopsComment} objects **/ function getTopComments($module_id, $item_id, $order, $status = null) { $criteria = new CriteriaCompo(new Criteria('com_modid', intval($module_id))); $criteria->add(new Criteria('com_itemid', intval($item_id))); $criteria->add(new Criteria('com_pid', 0)); if (isset($status)) { $criteria->add(new Criteria('com_status', intval($status))); } $criteria->setOrder($order); return $this->getObjects($criteria); }
/** * Retrieve a whole thread * * @param int $comment_rootid * @param int $comment_id * @param int $status * * @return array Array of {@link XoopsComment} objects **/ function getThread($comment_rootid, $comment_id, $status = null) { $criteria = new CriteriaCompo(new Criteria('com_rootid', intval($comment_rootid))); $criteria->add(new Criteria('com_id', intval($comment_id), '>=')); if (isset($status)) { $criteria->add(new Criteria('com_status', intval($status))); } return $this->getObjects($criteria); }
/** * Update * * @param object &$comment {@link XoopsComment} object * @param string $field_name Name of the field * @param mixed $field_value Value to write * * @return bool **/ function updateByField(&$comment, $field_name, $field_value) { $comment->unsetNew(); $comment->setVar($field_name, $field_value); return $this->insert($comment); }
/** * Delete all comments for one whole module * * @param int $module_id ID of the module * @return bool **/ function deleteByModule($module_id) { return $this->deleteAll(new Criteria('com_modid', intval($module_id))); } } ?>
|