From: <ok...@us...> - 2003-01-07 21:32:56
|
Update of /cvsroot/xoops/xoops2/kernel/comment/handler In directory sc8-pr-cvs1:/tmp/cvs-serv14503/kernel/comment/handler Added Files: comment.php Log Message: added global comments feature --- NEW FILE: comment.php --- <?php // $Id: comment.php,v 1.1 2003/01/07 21:32:50 okazu 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/) // // ------------------------------------------------------------------------- // $xoopsHandlerName = 'XoopsCommentHandler'; class XoopsCommentHandler { // private // holds reference to comment manager(DAO) class var $_manager; function XoopsCommentHandler() { $mFactory =& XoopsManagerFactory::getInstance(); $this->_manager =& $mFactory->get(MANAGER_COMMENT); } function &create() { return $this->_manager->create(); } function &get($id) { return $this->_manager->get($id); } function insert(&$comment) { return $this->_manager->insert($comment); } function delete(&$comment) { return $this->_manager->delete($comment); } function &getObjects($criteria = null) { return $this->_manager->getObjects($criteria); } function getCount($criteria = null) { return $this->_manager->getCount($criteria); } function &getList($criteria = null) { $comments =& $this->_manager->getObjects($criteria); $count = count($comments); $ret = array(); for ($i = 0; $i < $count; $i++) { $ret[$comments[$i]->getVar('comment_id')] = $comments[$i]->getVar('comment_title'); } return $ret; } function &getByItemId($module_id, $item_id, $order = null, $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))); } if (isset($order)) { $criteria->setOrder($order); } return $this->_manager->getObjects($criteria); } 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->_manager->getObjects($criteria); } 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->_manager->getObjects($criteria); } function updateByField(&$comment, $field_name, $field_value) { $comment->unsetNew(); $comment->setVar($field_name, $field_value); return $this->_manager->insert($comment); } function deleteByModule($module_id) { return $this->_manager->deleteAll(new Criteria('com_modid', intval($module_id))); } } ?> |