| 1 | <?php |
|---|
| 2 | // $Id: comment.php,v 1.2 2005/03/18 12:52:14 onokazu Exp $ |
|---|
| 3 | // ------------------------------------------------------------------------ // |
|---|
| 4 | // XOOPS - PHP Content Management System // |
|---|
| 5 | // Copyright (c) 2000 XOOPS.org // |
|---|
| 6 | // <http://www.xoops.org/> // |
|---|
| 7 | // ------------------------------------------------------------------------ // |
|---|
| 8 | // This program is free software; you can redistribute it and/or modify // |
|---|
| 9 | // it under the terms of the GNU General Public License as published by // |
|---|
| 10 | // the Free Software Foundation; either version 2 of the License, or // |
|---|
| 11 | // (at your option) any later version. // |
|---|
| 12 | // // |
|---|
| 13 | // You may not change or alter any portion of this comment or credits // |
|---|
| 14 | // of supporting developers from this source code or any supporting // |
|---|
| 15 | // source code which is considered copyrighted (c) material of the // |
|---|
| 16 | // original comment or credit authors. // |
|---|
| 17 | // // |
|---|
| 18 | // This program is distributed in the hope that it will be useful, // |
|---|
| 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|---|
| 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|---|
| 21 | // GNU General Public License for more details. // |
|---|
| 22 | // // |
|---|
| 23 | // You should have received a copy of the GNU General Public License // |
|---|
| 24 | // along with this program; if not, write to the Free Software // |
|---|
| 25 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
|---|
| 26 | // ------------------------------------------------------------------------ // |
|---|
| 27 | // Author: Kazumi Ono (AKA onokazu) // |
|---|
| 28 | // URL: http://www.xoops.org/ http://jp.xoops.org/ http://www.myweb.ne.jp/ // |
|---|
| 29 | // Project: The XOOPS Project (http://www.xoops.org/) // |
|---|
| 30 | // ------------------------------------------------------------------------- // |
|---|
| 31 | |
|---|
| 32 | if (!defined('XOOPS_ROOT_PATH')) { |
|---|
| 33 | exit(); |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | /** |
|---|
| 37 | * |
|---|
| 38 | * |
|---|
| 39 | * @package kernel |
|---|
| 40 | * |
|---|
| 41 | * @author Kazumi Ono <[email protected]> |
|---|
| 42 | * @copyright copyright (c) 2000-2003 XOOPS.org |
|---|
| 43 | */ |
|---|
| 44 | |
|---|
| 45 | /** |
|---|
| 46 | * A Comment |
|---|
| 47 | * |
|---|
| 48 | * @package kernel |
|---|
| 49 | * |
|---|
| 50 | * @author Kazumi Ono <[email protected]> |
|---|
| 51 | * @copyright copyright (c) 2000-2003 XOOPS.org |
|---|
| 52 | */ |
|---|
| 53 | class XoopsComment extends XoopsObject |
|---|
| 54 | { |
|---|
| 55 | |
|---|
| 56 | /** |
|---|
| 57 | * Constructor |
|---|
| 58 | **/ |
|---|
| 59 | function XoopsComment() |
|---|
| 60 | { |
|---|
| 61 | $this->XoopsObject(); |
|---|
| 62 | $this->initVar('com_id', XOBJ_DTYPE_INT, null, false); |
|---|
| 63 | $this->initVar('com_pid', XOBJ_DTYPE_INT, 0, false); |
|---|
| 64 | $this->initVar('com_modid', XOBJ_DTYPE_INT, null, false); |
|---|
| 65 | $this->initVar('com_icon', XOBJ_DTYPE_OTHER, null, false); |
|---|
| 66 | $this->initVar('com_title', XOBJ_DTYPE_TXTBOX, null, true, 255, true); |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | //Added By Viva(2005/12/13) ---> |
|---|
| 70 | $this->initVar('com_poster_name',XOBJ_DTYPE_TXTBOX,null,true,60,true); |
|---|
| 71 | //Added By Viva(2005/12/13) <--- |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | $this->initVar('com_text', XOBJ_DTYPE_TXTAREA, null, true, null, true); |
|---|
| 75 | $this->initVar('com_created', XOBJ_DTYPE_INT, 0, false); |
|---|
| 76 | $this->initVar('com_modified', XOBJ_DTYPE_INT, 0, false); |
|---|
| 77 | $this->initVar('com_uid', XOBJ_DTYPE_INT, 0, true); |
|---|
| 78 | $this->initVar('com_ip', XOBJ_DTYPE_OTHER, null, false); |
|---|
| 79 | $this->initVar('com_sig', XOBJ_DTYPE_INT, 0, false); |
|---|
| 80 | $this->initVar('com_itemid', XOBJ_DTYPE_INT, 0, false); |
|---|
| 81 | $this->initVar('com_rootid', XOBJ_DTYPE_INT, 0, false); |
|---|
| 82 | $this->initVar('com_status', XOBJ_DTYPE_INT, 0, false); |
|---|
| 83 | $this->initVar('com_exparams', XOBJ_DTYPE_OTHER, null, false, 255); |
|---|
| 84 | $this->initVar('dohtml', XOBJ_DTYPE_INT, 0, false); |
|---|
| 85 | $this->initVar('dosmiley', XOBJ_DTYPE_INT, 0, false); |
|---|
| 86 | $this->initVar('doxcode', XOBJ_DTYPE_INT, 0, false); |
|---|
| 87 | $this->initVar('doimage', XOBJ_DTYPE_INT, 0, false); |
|---|
| 88 | $this->initVar('dobr', XOBJ_DTYPE_INT, 0, false); |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | /** |
|---|
| 92 | * Is this comment on the root level? |
|---|
| 93 | * |
|---|
| 94 | * @return bool |
|---|
| 95 | **/ |
|---|
| 96 | function isRoot() |
|---|
| 97 | { |
|---|
| 98 | return ($this->getVar('com_id') == $this->getVar('com_rootid')); |
|---|
| 99 | } |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | /** |
|---|
| 103 | * XOOPS comment handler class. |
|---|
| 104 | * |
|---|
| 105 | * This class is responsible for providing data access mechanisms to the data source |
|---|
| 106 | * of XOOPS comment class objects. |
|---|
| 107 | * |
|---|
| 108 | * |
|---|
| 109 | * @package kernel |
|---|
| 110 | * @subpackage comment |
|---|
| 111 | * |
|---|
| 112 | * @author Kazumi Ono <[email protected]> |
|---|
| 113 | * @copyright copyright (c) 2000-2003 XOOPS.org |
|---|
| 114 | */ |
|---|
| 115 | class XoopsCommentHandler extends XoopsObjectHandler |
|---|
| 116 | { |
|---|
| 117 | |
|---|
| 118 | /** |
|---|
| 119 | * Create a {@link XoopsComment} |
|---|
| 120 | * |
|---|
| 121 | * @param bool $isNew Flag the object as "new"? |
|---|
| 122 | * |
|---|
| 123 | * @return object |
|---|
| 124 | */ |
|---|
| 125 | function &create($isNew = true) |
|---|
| 126 | { |
|---|
| 127 | $comment = new XoopsComment(); |
|---|
| 128 | if ($isNew) { |
|---|
| 129 | $comment->setNew(); |
|---|
| 130 | } |
|---|
| 131 | return $comment; |
|---|
| 132 | } |
|---|
| 133 | |
|---|
| 134 | /** |
|---|
| 135 | * Retrieve a {@link XoopsComment} |
|---|
| 136 | * |
|---|
| 137 | * @param int $id ID |
|---|
| 138 | * |
|---|
| 139 | * @return object {@link XoopsComment}, FALSE on fail |
|---|
| 140 | **/ |
|---|
| 141 | function &get($id) |
|---|
| 142 | { |
|---|
| 143 | $id = intval($id); |
|---|
| 144 | if ($id > 0) { |
|---|
| 145 | $sql = 'SELECT * FROM '.$this->db->prefix('xoopscomments').' WHERE com_id='.$id; |
|---|
| 146 | if (!$result = $this->db->query($sql)) { |
|---|
| 147 | return false; |
|---|
| 148 | } |
|---|
| 149 | $numrows = $this->db->getRowsNum($result); |
|---|
| 150 | if ($numrows == 1) { |
|---|
| 151 | $comment = new XoopsComment(); |
|---|
| 152 | $comment->assignVars($this->db->fetchArray($result)); |
|---|
| 153 | return $comment; |
|---|
| 154 | } |
|---|
| 155 | } |
|---|
| 156 | return false; |
|---|
| 157 | } |
|---|
| 158 | |
|---|
| 159 | /** |
|---|
| 160 | * Write a comment to database |
|---|
| 161 | * |
|---|
| 162 | * @param object &$comment |
|---|
| 163 | * |
|---|
| 164 | * @return bool |
|---|
| 165 | **/ |
|---|
| 166 | function insert(&$comment) |
|---|
| 167 | { |
|---|
| 168 | if (strtolower(get_class($comment)) != 'xoopscomment') { |
|---|
| 169 | return false; |
|---|
| 170 | } |
|---|
| 171 | if (!$comment->isDirty()) { |
|---|
| 172 | return true; |
|---|
| 173 | } |
|---|
| 174 | if (!$comment->cleanVars()) { |
|---|
| 175 | return false; |
|---|
| 176 | } |
|---|
| 177 | foreach ($comment->cleanVars as $k => $v) { |
|---|
| 178 | ${$k} = $v; |
|---|
| 179 | } |
|---|
| 180 | if ($comment->isNew()) { |
|---|
| 181 | $com_id = $this->db->genId('xoopscomments_com_id_seq'); |
|---|
| 182 | |
|---|
| 183 | |
|---|
| 184 | //Modified By Viva(2005/12/13) ---> |
|---|
| 185 | //$sql = sprintf("INSERT INTO %s (com_id, com_pid, com_modid, com_icon, com_title, com_text, com_created, com_modified, com_uid, com_ip, com_sig, com_itemid, com_rootid, com_status, com_exparams, dohtml, dosmiley, doxcode, doimage, dobr) VALUES (%u, %u, %u, %s, %s, %s, %u, %u, %u, %s, %u, %u, %u, %u, %s, %u, %u, %u, %u, %u)", $this->db->prefix('xoopscomments'), $com_id, $com_pid, $com_modid, $this->db->quoteString($com_icon), $this->db->quoteString($com_title), $this->db->quoteString($com_text), $com_created, $com_modified, $com_uid, $this->db->quoteString($com_ip), $com_sig, $com_itemid, $com_rootid, $com_status, $this->db->quoteString($com_exparams), $dohtml, $dosmiley, $doxcode, $doimage, $dobr); |
|---|
| 186 | $sql = sprintf("INSERT INTO %s (com_id, com_pid, com_modid, com_icon, com_title, com_text, com_created, com_modified, com_uid, com_ip, com_sig, com_itemid, com_rootid, com_status, com_exparams, dohtml, dosmiley, doxcode, doimage, dobr, com_poster_name) VALUES (%u, %u, %u, %s, %s, %s, %u, %u, %u, %s, %u, %u, %u, %u, %s, %u, %u, %u, %u, %u, %s)", $this->db->prefix('xoopscomments'), $com_id, $com_pid, $com_modid, $this->db->quoteString($com_icon), $this->db->quoteString($com_title), $this->db->quoteString($com_text), $com_created, $com_modified, $com_uid, $this->db->quoteString($com_ip), $com_sig, $com_itemid, $com_rootid, $com_status, $this->db->quoteString($com_exparams), $dohtml, $dosmiley, $doxcode, $doimage, $dobr, $this->db->quoteString($com_poster_name)); |
|---|
| 187 | //Modified By Viva(2005/12/13) <--- |
|---|
| 188 | |
|---|
| 189 | |
|---|
| 190 | } else { |
|---|
| 191 | $sql = sprintf("UPDATE %s SET com_pid = %u, com_icon = %s, com_title = %s, com_text = %s, com_created = %u, com_modified = %u, com_uid = %u, com_ip = %s, com_sig = %u, com_itemid = %u, com_rootid = %u, com_status = %u, com_exparams = %s, dohtml = %u, dosmiley = %u, doxcode = %u, doimage = %u, dobr = %u WHERE com_id = %u", $this->db->prefix('xoopscomments'), $com_pid, $this->db->quoteString($com_icon), $this->db->quoteString($com_title), $this->db->quoteString($com_text), $com_created, $com_modified, $com_uid, $this->db->quoteString($com_ip), $com_sig, $com_itemid, $com_rootid, $com_status, $this->db->quoteString($com_exparams), $dohtml, $dosmiley, $doxcode, $doimage, $dobr, $com_id); |
|---|
| 192 | } |
|---|
| 193 | if (!$result = $this->db->query($sql)) { |
|---|
| 194 | return false; |
|---|
| 195 | } |
|---|
| 196 | if (empty($com_id)) { |
|---|
| 197 | $com_id = $this->db->getInsertId(); |
|---|
| 198 | } |
|---|
| 199 | $comment->assignVar('com_id', $com_id); |
|---|
| 200 | return true; |
|---|
| 201 | } |
|---|
| 202 | |
|---|
| 203 | /** |
|---|
| 204 | * Delete a {@link XoopsComment} from the database |
|---|
| 205 | * |
|---|
| 206 | * @param object &$comment |
|---|
| 207 | * |
|---|
| 208 | * @return bool |
|---|
| 209 | **/ |
|---|
| 210 | function delete(&$comment) |
|---|
| 211 | { |
|---|
| 212 | if (strtolower(get_class($comment)) != 'xoopscomment') { |
|---|
| 213 | return false; |
|---|
| 214 | } |
|---|
| 215 | $sql = sprintf("DELETE FROM %s WHERE com_id = %u", $this->db->prefix('xoopscomments'), $comment->getVar('com_id')); |
|---|
| 216 | if (!$result = $this->db->query($sql)) { |
|---|
| 217 | return false; |
|---|
| 218 | } |
|---|
| 219 | return true; |
|---|
| 220 | } |
|---|
| 221 | |
|---|
| 222 | /** |
|---|
| 223 | * Get some {@link XoopsComment}s |
|---|
| 224 | * |
|---|
| 225 | * @param object $criteria |
|---|
| 226 | * @param bool $id_as_key Use IDs as keys into the array? |
|---|
| 227 | * |
|---|
| 228 | * @return array Array of {@link XoopsComment} objects |
|---|
| 229 | **/ |
|---|
| 230 | function &getObjects($criteria = null, $id_as_key = false) |
|---|
| 231 | { |
|---|
| 232 | $ret = array(); |
|---|
| 233 | $limit = $start = 0; |
|---|
| 234 | $sql = 'SELECT * FROM '.$this->db->prefix('xoopscomments'); |
|---|
| 235 | if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
|---|
| 236 | $sql .= ' '.$criteria->renderWhere(); |
|---|
| 237 | $sort = ($criteria->getSort() != '') ? $criteria->getSort() : 'com_id'; |
|---|
| 238 | $sql .= ' ORDER BY '.$sort.' '.$criteria->getOrder(); |
|---|
| 239 | $limit = $criteria->getLimit(); |
|---|
| 240 | $start = $criteria->getStart(); |
|---|
| 241 | } |
|---|
| 242 | $result = $this->db->query($sql, $limit, $start); |
|---|
| 243 | if (!$result) { |
|---|
| 244 | return $ret; |
|---|
| 245 | } |
|---|
| 246 | while ($myrow = $this->db->fetchArray($result)) { |
|---|
| 247 | $comment = new XoopsComment(); |
|---|
| 248 | $comment->assignVars($myrow); |
|---|
| 249 | if (!$id_as_key) { |
|---|
| 250 | $ret[] =& $comment; |
|---|
| 251 | } else { |
|---|
| 252 | $ret[$myrow['com_id']] =& $comment; |
|---|
| 253 | } |
|---|
| 254 | unset($comment); |
|---|
| 255 | } |
|---|
| 256 | return $ret; |
|---|
| 257 | } |
|---|
| 258 | |
|---|
| 259 | /** |
|---|
| 260 | * Count Comments |
|---|
| 261 | * |
|---|
| 262 | * @param object $criteria {@link CriteriaElement} |
|---|
| 263 | * |
|---|
| 264 | * @return int Count |
|---|
| 265 | **/ |
|---|
| 266 | function getCount($criteria = null) |
|---|
| 267 | { |
|---|
| 268 | $sql = 'SELECT COUNT(*) FROM '.$this->db->prefix('xoopscomments'); |
|---|
| 269 | if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
|---|
| 270 | $sql .= ' '.$criteria->renderWhere(); |
|---|
| 271 | } |
|---|
| 272 | if (!$result =& $this->db->query($sql)) { |
|---|
| 273 | return 0; |
|---|
| 274 | } |
|---|
| 275 | list($count) = $this->db->fetchRow($result); |
|---|
| 276 | return $count; |
|---|
| 277 | } |
|---|
| 278 | |
|---|
| 279 | /** |
|---|
| 280 | * Delete multiple comments |
|---|
| 281 | * |
|---|
| 282 | * @param object $criteria {@link CriteriaElement} |
|---|
| 283 | * |
|---|
| 284 | * @return bool |
|---|
| 285 | **/ |
|---|
| 286 | function deleteAll($criteria = null) |
|---|
| 287 | { |
|---|
| 288 | $sql = 'DELETE FROM '.$this->db->prefix('xoopscomments'); |
|---|
| 289 | if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
|---|
| 290 | $sql .= ' '.$criteria->renderWhere(); |
|---|
| 291 | } |
|---|
| 292 | if (!$result = $this->db->query($sql)) { |
|---|
| 293 | return false; |
|---|
| 294 | } |
|---|
| 295 | return true; |
|---|
| 296 | } |
|---|
| 297 | |
|---|
| 298 | /** |
|---|
| 299 | * Get a list of comments |
|---|
| 300 | * |
|---|
| 301 | * @param object $criteria {@link CriteriaElement} |
|---|
| 302 | * |
|---|
| 303 | * @return array Array of raw database records |
|---|
| 304 | **/ |
|---|
| 305 | function &getList($criteria = null) |
|---|
| 306 | { |
|---|
| 307 | $comments =& $this->getObjects($criteria, true); |
|---|
| 308 | $ret = array(); |
|---|
| 309 | foreach (array_keys($comments) as $i) { |
|---|
| 310 | $ret[$i] = $comments[$i]->getVar('com_title'); |
|---|
| 311 | } |
|---|
| 312 | return $ret; |
|---|
| 313 | } |
|---|
| 314 | |
|---|
| 315 | /** |
|---|
| 316 | * Retrieves comments for an item |
|---|
| 317 | * |
|---|
| 318 | * @param int $module_id Module ID |
|---|
| 319 | * @param int $item_id Item ID |
|---|
| 320 | * @param string $order Sort order |
|---|
| 321 | * @param int $status Status of the comment |
|---|
| 322 | * @param int $limit Max num of comments to retrieve |
|---|
| 323 | * @param int $start Start offset |
|---|
| 324 | * |
|---|
| 325 | * @return array Array of {@link XoopsComment} objects |
|---|
| 326 | **/ |
|---|
| 327 | function &getByItemId($module_id, $item_id, $order = null, $status = null, $limit = null, $start = 0) |
|---|
| 328 | { |
|---|
| 329 | $criteria = new CriteriaCompo(new Criteria('com_modid', intval($module_id))); |
|---|
| 330 | $criteria->add(new Criteria('com_itemid', intval($item_id))); |
|---|
| 331 | if (isset($status)) { |
|---|
| 332 | $criteria->add(new Criteria('com_status', intval($status))); |
|---|
| 333 | } |
|---|
| 334 | if (isset($order)) { |
|---|
| 335 | $criteria->setOrder($order); |
|---|
| 336 | } |
|---|
| 337 | if (isset($limit)) { |
|---|
| 338 | $criteria->setLimit($limit); |
|---|
| 339 | $criteria->setStart($start); |
|---|
| 340 | } |
|---|
| 341 | return $this->getObjects($criteria); |
|---|
| 342 | } |
|---|
| 343 | |
|---|
| 344 | /** |
|---|
| 345 | * Gets total number of comments for an item |
|---|
| 346 | * |
|---|
| 347 | * @param int $module_id Module ID |
|---|
| 348 | * @param int $item_id Item ID |
|---|
| 349 | * @param int $status Status of the comment |
|---|
| 350 | * |
|---|
| 351 | * @return array Array of {@link XoopsComment} objects |
|---|
| 352 | **/ |
|---|
| 353 | function &getCountByItemId($module_id, $item_id, $status = null) |
|---|
| 354 | { |
|---|
| 355 | $criteria = new CriteriaCompo(new Criteria('com_modid', intval($module_id))); |
|---|
| 356 | $criteria->add(new Criteria('com_itemid', intval($item_id))); |
|---|
| 357 | if (isset($status)) { |
|---|
| 358 | $criteria->add(new Criteria('com_status', intval($status))); |
|---|
| 359 | } |
|---|
| 360 | return $this->getCount($criteria); |
|---|
| 361 | } |
|---|
| 362 | |
|---|
| 363 | |
|---|
| 364 | /** |
|---|
| 365 | * Get the top {@link XoopsComment}s |
|---|
| 366 | * |
|---|
| 367 | * @param int $module_id |
|---|
| 368 | * @param int $item_id |
|---|
| 369 | * @param strint $order |
|---|
| 370 | * @param int $status |
|---|
| 371 | * |
|---|
| 372 | * @return array Array of {@link XoopsComment} objects |
|---|
| 373 | **/ |
|---|
| 374 | function &getTopComments($module_id, $item_id, $order, $status = null) |
|---|
| 375 | { |
|---|
| 376 | $criteria = new CriteriaCompo(new Criteria('com_modid', intval($module_id))); |
|---|
| 377 | $criteria->add(new Criteria('com_itemid', intval($item_id))); |
|---|
| 378 | $criteria->add(new Criteria('com_pid', 0)); |
|---|
| 379 | if (isset($status)) { |
|---|
| 380 | $criteria->add(new Criteria('com_status', intval($status))); |
|---|
| 381 | } |
|---|
| 382 | $criteria->setOrder($order); |
|---|
| 383 | return $this->getObjects($criteria); |
|---|
| 384 | } |
|---|
| 385 | |
|---|
| 386 | /** |
|---|
| 387 | * Retrieve a whole thread |
|---|
| 388 | * |
|---|
| 389 | * @param int $comment_rootid |
|---|
| 390 | * @param int $comment_id |
|---|
| 391 | * @param int $status |
|---|
| 392 | * |
|---|
| 393 | * @return array Array of {@link XoopsComment} objects |
|---|
| 394 | **/ |
|---|
| 395 | function &getThread($comment_rootid, $comment_id, $status = null) |
|---|
| 396 | { |
|---|
| 397 | $criteria = new CriteriaCompo(new Criteria('com_rootid', intval($comment_rootid))); |
|---|
| 398 | $criteria->add(new Criteria('com_id', intval($comment_id), '>=')); |
|---|
| 399 | if (isset($status)) { |
|---|
| 400 | $criteria->add(new Criteria('com_status', intval($status))); |
|---|
| 401 | } |
|---|
| 402 | return $this->getObjects($criteria); |
|---|
| 403 | } |
|---|
| 404 | |
|---|
| 405 | /** |
|---|
| 406 | * Update |
|---|
| 407 | * |
|---|
| 408 | * @param object &$comment {@link XoopsComment} object |
|---|
| 409 | * @param string $field_name Name of the field |
|---|
| 410 | * @param mixed $field_value Value to write |
|---|
| 411 | * |
|---|
| 412 | * @return bool |
|---|
| 413 | **/ |
|---|
| 414 | function updateByField(&$comment, $field_name, $field_value) |
|---|
| 415 | { |
|---|
| 416 | $comment->unsetNew(); |
|---|
| 417 | $comment->setVar($field_name, $field_value); |
|---|
| 418 | return $this->insert($comment); |
|---|
| 419 | } |
|---|
| 420 | |
|---|
| 421 | /** |
|---|
| 422 | * Delete all comments for one whole module |
|---|
| 423 | * |
|---|
| 424 | * @param int $module_id ID of the module |
|---|
| 425 | * @return bool |
|---|
| 426 | **/ |
|---|
| 427 | function deleteByModule($module_id) |
|---|
| 428 | { |
|---|
| 429 | return $this->deleteAll(new Criteria('com_modid', intval($module_id))); |
|---|
| 430 | } |
|---|
| 431 | |
|---|
| 432 | /** |
|---|
| 433 | * Change a value in multiple comments |
|---|
| 434 | * |
|---|
| 435 | * @param string $fieldname Name of the field |
|---|
| 436 | * @param string $fieldvalue Value to write |
|---|
| 437 | * @param object $criteria {@link CriteriaElement} |
|---|
| 438 | * |
|---|
| 439 | * @return bool |
|---|
| 440 | **/ |
|---|
| 441 | /* |
|---|
| 442 | function updateAll($fieldname, $fieldvalue, $criteria = null) |
|---|
| 443 | { |
|---|
| 444 | $set_clause = is_numeric($fieldvalue) ? $filedname.' = '.$fieldvalue : $filedname.' = '.$this->db->quoteString($fieldvalue); |
|---|
| 445 | $sql = 'UPDATE '.$this->db->prefix('xoopscomments').' SET '.$set_clause; |
|---|
| 446 | if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { |
|---|
| 447 | $sql .= ' '.$criteria->renderWhere(); |
|---|
| 448 | } |
|---|
| 449 | if (!$result = $this->db->query($sql)) { |
|---|
| 450 | return false; |
|---|
| 451 | } |
|---|
| 452 | return true; |
|---|
| 453 | } |
|---|
| 454 | */ |
|---|
| 455 | } |
|---|
| 456 | ?> |
|---|