⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class.newsstory.php

📁 在综合英文版XOOPS 2.09, 2.091, 2.092 的基础上正式发布XOOPS 2.09中文版 XOOPS 2.09x 版主要是PHP5升级、bug修正和安全补正: 1 全面兼容PHP 5.
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php// $Id: class.newsstory.php,v 1.17 2004/05/25 10:53:08 mithyt2 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 //// ------------------------------------------------------------------------- //include_once XOOPS_ROOT_PATH."/class/xoopsstory.php";include_once XOOPS_ROOT_PATH.'/include/comment_constants.php';class NewsStory extends XoopsStory{	var $newstopic;   // XoopsTopic object	function NewsStory($storyid=-1)	{		$this->db =& Database::getInstance();		$this->table = $this->db->prefix("stories");		$this->topicstable = $this->db->prefix("topics");		if (is_array($storyid)) {			$this->makeStory($storyid);			$this->newstopic = $this->topic();		} elseif($storyid != -1) {			$this->getStory(intval($storyid));			$this->newstopic = $this->topic();		}	}	function getAllPublished($limit=0, $start=0, $checkRight = false, $topic=0, $ihome=0, $asobject=true)	{		$db =& Database::getInstance();		$myts =& MyTextSanitizer::getInstance();		$ret = array();		$sql = "SELECT * FROM ".$db->prefix("stories")." WHERE published > 0 AND published <= ".time()." AND (expired = 0 OR expired > ".time().")";		if ( !empty($topic) ) {			/*			if(is_array($topic) && count($topic)>0)				$sql .= " AND topicid IN (".implode(',', $topic).") AND (ihome=1 OR ihome=0)";			else			*/				$sql .= " AND topicid=".intval($topic)." AND (ihome=1 OR ihome=0)";		} else {		    if ($checkRight) {		        global $xoopsUser;		        $module_handler =& xoops_gethandler('module');		        $newsModule =& $module_handler->getByDirname('news');		        $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;		        $gperm_handler =& xoops_gethandler('groupperm');		        $topics = $gperm_handler->getItemIds('news_view', $groups, $newsModule->getVar('mid'));		        $topics = implode(',', $topics);		        $sql .= " AND topicid IN (".$topics.")";		    }			if (intval($ihome)==0) {				$sql .= " AND ihome=0";			}		} 		$sql .= " ORDER BY published DESC";		$result = $db->query($sql,intval($limit),intval($start));		while ($myrow = $db->fetchArray($result)) {			if ( $asobject ) {				$ret[] = new NewsStory($myrow);			} else {				$ret[$myrow['storyid']] = $myts->makeTboxData4Show($myrow['title']);			}		}		return $ret;	}	// added new function to get all expired stories	function getAllExpired($limit=0, $start=0, $topic=0, $ihome=0, $asobject=true)	{		$db =& Database::getInstance();		$myts =& MyTextSanitizer::getInstance();		$ret = array();		$sql = "SELECT * FROM ".$db->prefix("stories")." WHERE expired <= ".time()." AND expired > 0";		if ( !empty($topic) ) {			$sql .= " AND topicid=".intval($topic)." AND (ihome=1 OR ihome=0)";		} else {			if ( intval($ihome) == 0 ) {				$sql .= " AND ihome=0";			}		} 		$sql .= " ORDER BY expired DESC";		$result = $db->query($sql,intval($limit),intval($start));		while ($myrow=$db->fetchArray($result)) {			if ( $asobject ) {				$ret[] = new NewsStory($myrow);			} else {				$ret[$myrow['storyid']] = $myts->makeTboxData4Show($myrow['title']);			}		}		return $ret;	}	function getAllAutoStory($limit=0, $asobject=true)	{		$db =& Database::getInstance();		$myts =& MyTextSanitizer::getInstance();		$ret = array();		$sql = "SELECT * FROM ".$db->prefix("stories")." WHERE published > ".time()." ORDER BY published ASC";		$result = $db->query($sql,intval($limit),0);		while ($myrow=$db->fetchArray($result)) {			if ($asobject) {				$ret[] = new NewsStory($myrow);			} else {				$ret[$myrow['storyid']] = $myts->makeTboxData4Show($myrow['title']);			}		}		return $ret;	}	/*	* Get all submitted stories awaiting approval	*	* @param int $limit Denotes where to start the query	* @param boolean $asobject true will return the stories as an array of objects, false will return storyid => title	* @param boolean $checkRight whether to check the user's rights to topics	*/	function getAllSubmitted($limit=0, $asobject=true, $checkRight = false)	{		$db =& Database::getInstance();		$myts =& MyTextSanitizer::getInstance();		$ret = array();		$criteria = new CriteriaCompo(new Criteria('published', 0));		if ($checkRight) {		    global $xoopsUser;		    if (!is_object($xoopsUser)) {		        return $ret;		    }		    $groups = $xoopsUser->getGroups();		    $gperm_handler =& xoops_gethandler('groupperm');		    $module_handler =& xoops_gethandler('module');		    $newsmodule =& $module_handler->getByDirname('news');		    $allowedtopics = $gperm_handler->getItemIds('news_approve', $groups, $newsmodule->getVar('mid'));		    $criteria2 = new CriteriaCompo();		    foreach ($allowedtopics as $key => $topicid) {		        $criteria2->add(new Criteria('topicid', $topicid), 'OR');		    }		    $criteria->add($criteria2);		}		$sql = "SELECT * FROM ".$db->prefix("stories");		$sql .= ' '.$criteria->renderWhere(). ' ORDER BY created DESC';		$result = $db->query($sql,intval($limit),0);		while ($myrow=$db->fetchArray($result)) {			if ($asobject) {				$ret[] = new NewsStory($myrow);			} else {				$ret[$myrow['storyid']] = $myts->makeTboxData4Show($myrow['title']);			}		}		return $ret;	}	function getByTopic($topicid, $limit=0)	{		$ret = array();		$db =& Database::getInstance();		$sql = "SELECT * FROM ".$db->prefix("stories")." WHERE topicid=".intval($topicid)." AND published > 0 AND published <= ".time()." AND (expired=0 OR expired > ".time().") ORDER BY published DESC";		$result = $db->query($sql, intval($limit), 0);		while( $myrow = $db->fetchArray($result) ){			$ret[] = new NewsStory($myrow);		}		return $ret;	}	function countByTopic($topicid=0)	{		$db =& Database::getInstance();		$sql = "SELECT COUNT(*) FROM ".$db->prefix("stories")."WHERE expired >= ".time();		if (intval($topicid) != 0 ) {			$sql .= " AND  topicid=".intval($topicid);		}		$result = $db->query($sql);		list($count) = $db->fetchRow($result);		return $count;	}	function countPublishedByTopic($topicid=0, $checkRight = false)	{		$db =& Database::getInstance();		$sql = "SELECT COUNT(*) FROM ".$db->prefix("stories")." WHERE published > 0 AND published <= ".time()." AND (expired = 0 OR expired > ".time().")";		if ( !empty($topicid) ) {			$sql .= " AND topicid=".intval($topicid);		} else {			$sql .= " AND ihome=0";			if ($checkRight) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -