调整数据作者管理SQL,改为右链接;调整逻辑处理;增加单数据下添加作者功能

This commit is contained in:
wlx 2012-05-31 14:58:18 +00:00
parent a671f7f776
commit eb5879c14f
2 changed files with 37 additions and 10 deletions

View File

@ -2153,8 +2153,6 @@ class Admin_DataController extends Zend_Controller_Action
/*
authorAction() 数据作者
*/
public function authorAction(){
@ -2162,7 +2160,7 @@ class Admin_DataController extends Zend_Controller_Action
$uuid = $this->_getParam('uuid');
if(empty($ac))
if(empty($ac) && empty($uuid))
{
$keywords = $this->_request->getParam('q');
@ -2170,7 +2168,7 @@ class Admin_DataController extends Zend_Controller_Action
$this->view->q = $keywords;
$sql = "select md.id,md.title,md.uuid,count(a.userid) as c from metadata md
LEFT JOIN mdauthor a ON md.uuid=a.uuid
right JOIN mdauthor a ON md.uuid=a.uuid
";
if(!empty($keywords))
@ -2181,7 +2179,7 @@ class Admin_DataController extends Zend_Controller_Action
}
$sql .= "GROUP by md.id,md.title,md.uuid,md.ts_created
ORDER BY c DESC,md.ts_created DESC";
ORDER BY md.ts_created DESC";
$sth = $this->db->prepare($sql);
$sth-> execute();
@ -2197,7 +2195,7 @@ class Admin_DataController extends Zend_Controller_Action
}//列表
if($ac == 'add')
else if($ac == 'add')
{
$this->_helper->layout->disableLayout();
@ -2288,7 +2286,7 @@ class Admin_DataController extends Zend_Controller_Action
}//ajax 添加作者
if($ac == "edit" || !empty($uuid))
else if(($ac == "edit" || $ac=="") && !empty($uuid))
{
$window = $this->_getParam('window');
@ -2316,7 +2314,7 @@ class Admin_DataController extends Zend_Controller_Action
}// 作者管理弹窗
if($ac == "del")
else if($ac == "del")
{
$this->_helper->layout->disableLayout();
@ -2341,7 +2339,7 @@ class Admin_DataController extends Zend_Controller_Action
}//移除作者
if($ac == 'update')
else if($ac == 'update')
{
$this->_helper->layout->disableLayout();

View File

@ -22,6 +22,8 @@ $this->breadcrumb()->setSeparator(' > ');
<div id="rightPanel">
<div id="loading" class="info info-box"></div>
<div id="datalist">
<h2><?php echo $this->authors[0]['title']; ?></h2>
<span id="addauthor_<?php echo $this->authors[0]['id'];?>"><a href="javascript:;" onclick="AddAuthor(<?php echo $this->authors[0]['id']; ?>,'<?php echo $this->authors[0]['uuid']; ?>')">添加作者</a></span>
<ul>
<?php
if(isset($this->authors))
@ -83,7 +85,34 @@ function remove(id){
'timeout': 30000
});
}
function AddAuthor(id,uuid){
$('#addauthor_'+id).html('用户名:<input type="text" id="authorInp_'+id+'"/><button class="btn btn-green" onclick="addAuthor('+id+',\''+uuid+'\')">添加</button>');
}
function addAuthor(id,uuid){
$.ajax({
'type':"POST",
'url':'/admin/data/author',
'data':'ac=add&uuid='+uuid+'&username='+$('#authorInp_'+id).val(),
'success':function(data){
if (typeof(data)=='object')
{
if(typeof(data.error)!='undefined')
{Alert(data.error);return false;}
if(typeof(data.msg)!='undefined')
{Alert(data.msg);}
if(typeof(data.added)!='undefined')
{$('#addauthor_'+id).html('<a href="javascript:;" onclick="AddAuthor('+id+',\''+uuid+'\')">添加作者</a>');}
}
else{
Alert('出现错误,请稍后再试');
}
},
'timeout': 30000,
'error': function(){
$.colorbox({'innerWidth':'50%','html':'<img src="/images/alert_big_error.png" /><h4>处理中出现错误,请刷新页面后重试</h4>'});
}
});
}
$('#loading').css("opacity","0.2");
$('#loading').ajaxComplete(function() {
$(this).css('display','none');