增加消息批量管理功能,增加消息处理机制

This commit is contained in:
Li Jianxuan 2011-11-17 09:37:17 +00:00
parent 747d016c2d
commit 5d7c23cb16
4 changed files with 146 additions and 8 deletions

View File

@ -253,6 +253,62 @@ class Admin_SysController extends Zend_Controller_Action
} }
} }
//读取所有消息
else if($do=="listall")
{
$sql = "SELECT * FROM messages m
LEFT JOIN messages_logs ml ON m.id=ml.mid
ORDER BY m.sendtime DESC";
$result = $this->db->query($sql);
$rows = $result->fetchAll();
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage($this->view->config->page->max);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
}
//标记为已读
else if($do=="close" && !empty($id))
{
$auth = Zend_Auth::getInstance();
if($auth->hasIdentity())
{
$user = $auth->getIdentity();
$userid = $user->id;
include_once("message.php");
$rs = message::read($this->db,$userid,$id);
$this->_redirect('/admin/sys/message');
}
}
//标记为已处理(不再推送给其他管理员)
else if($do=="over" && !empty($id))
{
$auth = Zend_Auth::getInstance();
if($auth->hasIdentity())
{
$user = $auth->getIdentity();
$userid = $user->id;
if($user->usertype == "administrator")
{
include_once("message.php");
$rs = message::over($this->db,$id);
if($rs){
echo "操作成功!";exit();
}else{
echo "操作失败!";exit();
}
}else{
echo "非法操作!";exit();
}
}else{
echo "非法操作!";exit();
}
}
//拉取新消息 //拉取新消息
else else
{ {

View File

@ -1,5 +1,6 @@
<ul> <ul>
<li class="title">系统管理</li> <li class="title">系统管理</li>
<li><a href="/admin/sys/emailtext">邮件模板管理</a></li> <li><a href="/admin/sys/emailtext">邮件模板管理</a></li>
<li><a href="/admin/sys/seekspace">文献平台同步</a></li> <li><a href="/admin/sys/seekspace">文献平台同步</a></li>
<li><a href="/admin/sys/message">管理消息</a></li>
</ul> </ul>

View File

@ -3,7 +3,9 @@
$this->headTitle('后台管理'); $this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - '); $this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/admin.css'); $this->headLink()->appendStylesheet('/css/admin.css');
$this->headScript()->appendFile('/js/jquery-1.6.4.min.js'); $this->headScript()->appendFile('/js/jquery-1.7.min.js');
$this->headScript()->appendFile('/static/js/jquery.jgrowl_minimized.js');
$this->headLink()->appendStylesheet('/static/css/jquery.jgrowl.css');
$this->breadcrumb('<a href="/">首页</a>'); $this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin">后台首页</a>'); $this->breadcrumb('<a href="/admin">后台首页</a>');
$this->breadcrumb('<a href="/admin/sys">系统管理</a>'); $this->breadcrumb('<a href="/admin/sys">系统管理</a>');
@ -28,10 +30,12 @@
</form> </form>
</div> </div>
<?php if($this->totle > 0) echo '共 <strong style="font-weight:bold;color:red;">'.$this->totle.'</strong> 条未读消息';?> <?php if($this->totle > 0) echo '共 <strong style="font-weight:bold;color:red;">'.$this->totle.'</strong> 条未读消息';?>
<form id="messages">
<table class="stylized"> <table class="stylized">
<thead> <thead>
<tr> <tr>
<td width='400'>标题</td> <td width='20'>选择</td>
<td width='380'>标题</td>
<td width="120">时间</td> <td width="120">时间</td>
<td width='180'>操作</td> <td width='180'>操作</td>
</tr> </tr>
@ -40,13 +44,58 @@
<tbody id="list"> <tbody id="list">
<?php foreach ($this->paginator as $item): ?> <?php foreach ($this->paginator as $item): ?>
<tr> <tr>
<td><a href="/admin/sys/message/do/read/id/<?php echo $item['id'];?>"><?php if(!empty($item['title'])) echo $item['title']; else echo "无标题"; ?></a></td> <td><input type="checkbox" name="id[]" value="<?php echo $item['id'];?>" /></td>
<td><a href="/admin/sys/message/do/read/id/<?php echo $item['id'];?>" <?php if (empty($item['uid'])) echo ' style="font-weight:bold"';?>><?php if(!empty($item['title'])) echo $item['title']; else echo "无标题"; ?></a></td>
<td><?php echo date("Y-m-d H:i",strtotime($item['sendtime'])); ?></td> <td><?php echo date("Y-m-d H:i",strtotime($item['sendtime'])); ?></td>
<td>[<a href="/admin/sys/message/do/read/id/<?php echo $item['id'];?>">查看</a>] [<a href="">标记为已读</a>]</td> <td>[<a href="/admin/sys/message/do/read/id/<?php echo $item['id'];?>">查看</a>] <?php if (empty($item['uid'])) echo '[<a href="/admin/sys/message/do/close/id/'.$item['id'].'">标记为已读</a>]'; ?></td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
<?php endif; ?> <?php endif; ?>
</table> </table>
</form>
<button class="btn" onclick="selall();">全选</button>
<button class="btn" onclick="unsel();">反选</button>
<button class="btn" onclick='unselall();'>全部取消</button>
<button class="btn" onclick="oversel();">标记为已处理</button>
<div class="pagenavi"><?= $this->paginator; ?></div> <div class="pagenavi"><?= $this->paginator; ?></div>
</div><script>$("#list tr").mouseover(function(){$(this).addClass("high")}).mouseout(function(){$(this).removeClass("high")})</script> </div><script>$("#list tr").mouseover(function(){$(this).addClass("high")}).mouseout(function(){$(this).removeClass("high")})
function selall(){
$("#messages :checkbox").attr('checked',true);
}
function unselall(){
$("#messages :checkbox").attr('checked',false);
}
function unsel(){
$("#messages :checkbox").each(function () {
$(this).attr("checked", !$(this).attr("checked"));
});
}
function getsel(){
var ids=new Array();
$("#messages :checkbox").each(function(){
if($(this).attr('checked')==true||$(this).attr('checked')=="checked")
{
ids.push($(this).val());
}
});
var allid=ids.join(',');
return allid;
}
function oversel(){
var id=getsel();if (id==null||id==''){alert('没有选择任何一项');return false;}
var d = confirm('确实要标记为已处理吗?标记后其他管理员将收不到该消息');
if(d==true){
$.ajax({
'type':"POST",
'url':"/admin/sys/message/do/over",
'data':'id='+id,
'success':function(html){
$.jGrowl(html, {"life":5000 });
}
});}
}
</script>

View File

@ -49,7 +49,7 @@ class message
try{ try{
$sql = "SELECT * FROM messages m $sql = "SELECT * FROM messages m
LEFT JOIN messages_logs ml ON m.id=ml.mid LEFT JOIN messages_logs ml ON m.id=ml.mid
WHERE ml.uid IS NULL"; WHERE ml.uid IS NULL AND m.status>=0 ";
if($type=="member") if($type=="member")
{ {
$sql .= " AND m.rid IN (0,$uid)"; $sql .= " AND m.rid IN (0,$uid)";
@ -70,6 +70,7 @@ class message
return $rev; return $rev;
} }
//返回单条消息
static function getOne($db,$uid,$id){ static function getOne($db,$uid,$id){
$rev = array(); $rev = array();
try{ try{
@ -92,4 +93,35 @@ class message
} }
return $rev; return $rev;
} }
//标记为已读
static function read($db,$uid,$mid){
$sql = "INSERT INTO messages_logs (uid,mid) VALUES ('$uid','$mid')";
if(@$db->exec($sql))
{
return true;
}else{
return false;
}
}
//标记为已处理(不再推送)
static function over($db,$mid){
$id = "";
if(!is_array($mid))
{
$id = $mid;
}else
{
$id = join(",",$mid);
}
$sql = "UPDATE messages SET status=-1 WHERE id IN ($id)";
if(@$db->exec($sql))
{
return true;
}else{
return false;
}
}
} }