<?php
/*
	[Office 515158] (C) 2009-2014 天生创想 Inc.
	$Id: news.class.php mobile $
*/
!defined('IN_TOA') && exit('Access Denied!');
function news_list($type=0,$USER=0){
	global $db,$_USER;
	$num = $db->result("SELECT COUNT(*) AS num FROM ".DB_TABLEPRE."news WHERE (receive like'%".get_realname($_USER->id)."%' or receive='0' or uid='".$_USER->id."') and type='".$type."' ORDER BY id desc LIMIT 0,50");
	$sql = "SELECT * FROM ".DB_TABLEPRE."news WHERE (receive like'%".get_realname($_USER->id)."%' or receive='0' or uid='".$_USER->id."')  and type='".$type."'  ORDER BY id desc LIMIT 0,50";
	$result = $db->fetch_all($sql);
	if($num>0){
		foreach ($result as $row) {
			$html.= '<li onClick=javascript:window.location="news.php?do=view&id='.$row['id'].'">'.$row['subject'].'</li>';
		}
	}else{
		$html.= '暂无内容';
	}
	return $html;
}
function news_type($type){
	switch ($type)
	{
		case 1:
		  return "新闻";
		  break;
		case 2:
		  return "图片新闻";
		  break;
		case 3:
		  return "公告";
		  break;
		case 4:
		  return "通知";
		  break;
		case 5:
		  return "大事记";
		  break;
		case 6:
		  return "电子期刊";
		  break;
		default:
		  return "错误类型";
	}
	return ;
}
?>