add doi action to authorcontroller
This commit is contained in:
parent
7fe6c51cc7
commit
cbbac48333
|
@ -33,7 +33,7 @@ $this->theme->AppendPlus($this,'colorbox');
|
|||
<div class="control-group">
|
||||
<label class="control-label" for="doi">doi</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="doi" name="doi" value="<?= isset($this->data['doi']) ? $this->data['doi']:"doi:10.3972/westdc.x.2013.db" ?>" />
|
||||
<input type="text" id="doi" name="doi" value="<?= (isset($this->data['doi'])&&!empty($this->data['doi'])) ? $this->data['doi']:"doi:10.3972/westdc.x.2013.db" ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
|
|
|
@ -3955,6 +3955,115 @@ class AuthorController extends Zend_Controller_Action
|
|||
|
||||
}//fund
|
||||
|
||||
public function doiAction()
|
||||
{
|
||||
//$this->_helper->layout->setLayout('administry');
|
||||
$ac = $this->_getParam('ac');
|
||||
$submit = $this->_getParam('submit');
|
||||
$uuid = $this->_getParam('uuid');
|
||||
|
||||
include_once("data/Doi.php");
|
||||
$doi = new Doi($this->db);
|
||||
include_once("helper/view.php");
|
||||
|
||||
if( empty($ac) || $ac == "index")
|
||||
{
|
||||
$uid = view::User('id');
|
||||
if(empty($uuid))
|
||||
{
|
||||
$rows = $doi->fetch($uid);
|
||||
view::addPaginator($rows,$this->view,$this->_request);
|
||||
}else{
|
||||
$this->_redirect('/author/doi/ac/edit/?uuid='.$uuid);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}//index
|
||||
|
||||
if($ac == "edit")
|
||||
{
|
||||
$this->_helper->viewRenderer('doi-add');
|
||||
$id = $this->_getParam('id');
|
||||
if(empty($uuid) && empty($id))
|
||||
{
|
||||
view::Msg('alert-error',"参数错误",-1);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(empty($submit)){
|
||||
if(!empty($uuid))
|
||||
{
|
||||
$this->view->uuid = $uuid;
|
||||
$this->view->data = $doi->view($uuid);
|
||||
if(empty($this->view->data))
|
||||
{
|
||||
include('data/Metadata.php');
|
||||
$md = new Metadata($this->db);
|
||||
$metadata = $md->view($uuid);
|
||||
$this->view->data = array(
|
||||
'uuid'=>$uuid,
|
||||
'title'=>$metadata['title'],
|
||||
'doi'=>$metadata['doi'],
|
||||
'url'=>"http://" . $_SERVER['HTTP_HOST'].'/data/'.$uuid,
|
||||
'publisher'=>view::User('realname'),
|
||||
);
|
||||
}else{
|
||||
$this->view->data['info'] = $doi->data_process_out($this->view->data);
|
||||
}
|
||||
}else{
|
||||
$this->view->data = $doi->view($uuid);
|
||||
$this->view->data['info'] = $doi->data_process_out($this->view->data);
|
||||
}
|
||||
}else{
|
||||
$data = $doi->_getParams($this->_request);
|
||||
$this->view->data = $data;
|
||||
$info = $doi->checkinfo($data['info']);
|
||||
if(!is_array($info)){
|
||||
$this->view->error = view::Error('alert-error',$info,-1);
|
||||
return true;
|
||||
}else{
|
||||
$data['info'] = $info;
|
||||
$data['info'] = $doi->sksort($data['info'],"order",SORT_DESC);
|
||||
}
|
||||
$uid = view::User('id');
|
||||
$state = $doi->update($data,$uuid,$uid);
|
||||
if($state)
|
||||
{
|
||||
$this->view->msg = view::Msg('alert-success',"修改成功!",'/author/doi/uuid/'.$uuid);
|
||||
return false;
|
||||
}else{
|
||||
$this->view->error = view::Error('alert-error',"修改失败",-1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}//edit
|
||||
|
||||
if($ac == "del")
|
||||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
|
||||
$id = $this->_getParam('id');
|
||||
|
||||
if(empty($id))
|
||||
{
|
||||
$this->jsonexit(array('error'=>'参数错误'));
|
||||
return true;
|
||||
}
|
||||
|
||||
if($doi->delete($id) == true)
|
||||
{
|
||||
$this->jsonexit(array('success'=>$id));
|
||||
return true;
|
||||
}else{
|
||||
$this->jsonexit(array('error'=>'删除失败'));
|
||||
return true;
|
||||
}
|
||||
|
||||
}//del
|
||||
|
||||
}//doi
|
||||
|
||||
/*
|
||||
* jsonexit() 退出并返回json数据
|
||||
*
|
||||
|
|
|
@ -48,7 +48,8 @@ $this->breadcrumb()->setSeparator(' > ');
|
|||
| <a href="/author/delegate/ac/cancel/uuid/<?php echo $item['uuid'];?>" onclick="return confirm('是否确定取消该数据的委托?');">取消委托</a>
|
||||
<?php }?> |
|
||||
<a href="/author/sendmail/uuid/<?php echo $item['uuid']; ?>">邮件通知</a> |
|
||||
<a href="/author/fund/ac/formd/uuid/<?php echo $item['uuid']; ?>">支持项目</a>
|
||||
<a href="/author/fund/ac/formd/uuid/<?php echo $item['uuid']; ?>">支持项目</a> |
|
||||
<a href="/author/doi/ac/edit/uuid/<?php echo $item['uuid']; ?>">DOI</a>
|
||||
】
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
<?php
|
||||
$this->headTitle($this->config->title->site);
|
||||
$this->headTitle($this->config->title->author);
|
||||
$this->headTitle()->setSeparator(' - ');
|
||||
//$this->headLink()->appendStylesheet('/css/admin.css');
|
||||
$this->breadcrumb('<a href="/">首页</a>');
|
||||
$this->breadcrumb('<a href="/admin/data">数据管理</a>');
|
||||
$this->breadcrumb('DOI');
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
$this->theme->AppendPlus($this,'colorbox');
|
||||
$this->headLink()->appendStylesheet('/css/author.css');
|
||||
?>
|
||||
<div class="row-fluid">
|
||||
<div class="span3">
|
||||
<?= $this->partial('author/navi.phtml'); ?>
|
||||
</div>
|
||||
<div class="span9">
|
||||
<div>
|
||||
<ul class="nav nav-tabs">
|
||||
<li><a href="/author/doi">浏览所有</a></li>
|
||||
<?php if(!empty($this->uuid)) {?>
|
||||
<li class="active"><a href="javascript:void(0);">编辑DOI</a></li>
|
||||
<?php }?>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="">
|
||||
<?php if(!empty($this->error)) { ?>
|
||||
<?= $this->error ?>
|
||||
<?php } ?>
|
||||
<?php if(!empty($this->msg)) { ?>
|
||||
<?= $this->msg ?>
|
||||
<?php } else{ ?>
|
||||
<form class="form-horizontal" method="post">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="doi">doi</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="doi" name="doi" readonly="readonly" value="<?= (isset($this->data['doi'])&&!empty($this->data['doi'])) ? $this->data['doi']:"doi:10.3972/westdc.x.2013.db" ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="uuid">uuid</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="uuid" name="uuid" readonly="readonly" value="<?= isset($this->data['uuid']) ? $this->data['uuid']:"" ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="publisher">发布者</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="publisher" name="publisher" value="<?= isset($this->data['publisher']) ? $this->data['publisher']:"" ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="url">url</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="url" name="url" readonly="readonly" value="<?= isset($this->data['url']) ? $this->data['url']:"" ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="title">title</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="title" name="title" readonly="readonly" value="<?= isset($this->data['title']) ? $this->data['title']:"" ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<?php if(empty($this->data['info']) || !is_array($this->data['info'])) {?>
|
||||
<div class="control-group infocontrol" id="info1">
|
||||
<label class="control-label" for="">info</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="info[1][author]" value="" placeholder="作者" />
|
||||
<input type="text" name="info[1][organization]" value="" placeholder="单位" />
|
||||
<input type="text" name="info[1][order]" value="" placeholder="排序" />
|
||||
</div>
|
||||
</div>
|
||||
<?php }else{ ?>
|
||||
<?php
|
||||
$index = 0;
|
||||
foreach($this->data['info'] as $k=>$v){
|
||||
$index ++;
|
||||
?>
|
||||
<div class="control-group infocontrol">
|
||||
<label class="control-label">info</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="info[<?= $k ?>][author]" value="<?= $v['author'] ?>" placeholder="作者" />
|
||||
<input type="text" name="info[<?= $k ?>][organization]" value="<?= $v['organization'] ?>" placeholder="单位" />
|
||||
<input type="text" name="info[<?= $k ?>][order]" value="<?= $v['order'] ?>" placeholder="排序" />
|
||||
<?php if($index>0){ ?>
|
||||
<a href="javascript:void(0);" onclick="RmInput(this)"> -删除</a>
|
||||
<?php }?>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<a href="javascript:void(0);" onclick="addinput()">+添加一条</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<input type="hidden" name="submit" value="1" />
|
||||
<?php if(!empty($this->id)) { ?>
|
||||
<input type="hidden" name="id" value=" <?=$this->id?> " />
|
||||
<?php } ?>
|
||||
<?php if(!empty($this->uuid)) { ?>
|
||||
<input type="hidden" name="uuid" value=" <?=$this->uuid?>" />
|
||||
<?php } ?>
|
||||
<button type="submit" class="btn btn-primary">提交</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function addinput(){
|
||||
var now_index = $('.infocontrol').length;
|
||||
var index = now_index + 1;
|
||||
html = '<div class="control-group infocontrol"><div class="controls">'
|
||||
+ '<input type="text" name="info[' + index + '][author]" placeholder="作者" /> '
|
||||
+ '<input type="text" name="info[' + index + '][organization]" placeholder="单位" /> '
|
||||
+ '<input type="text" name="info[' + index + '][order]" placeholder="排序" /> '
|
||||
+ '<a href="javascript:void(0);" onclick="RmInput(this)"> -删除</a>'
|
||||
+ '</div></div>';
|
||||
now_index = null;
|
||||
index = null;
|
||||
$('.infocontrol').last().after(html);
|
||||
}
|
||||
function RmInput(e){
|
||||
$e = $(e);
|
||||
$e.parent('div').parent('div.infocontrol').remove();
|
||||
}
|
||||
</script>
|
||||
<!-- //页面内容 -->
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
$this->headTitle($this->config->title->site);
|
||||
$this->headTitle($this->config->title->author);
|
||||
$this->headTitle()->setSeparator(' - ');
|
||||
$this->breadcrumb('<a href="/">首页</a>');
|
||||
$this->breadcrumb('<a href="/admin/data">数据管理</a>');
|
||||
$this->headLink()->appendStylesheet('/css/author.css');
|
||||
$this->breadcrumb('DOI');
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
$this->theme->AppendPlus($this,'colorbox');
|
||||
$this->theme->AppendPlus($this,'admin_plugin');
|
||||
?>
|
||||
<style>
|
||||
table thead tr th {background:#EBF2F6;}
|
||||
</style>
|
||||
<div class="row-fluid">
|
||||
<div class="span3">
|
||||
<?= $this->partial('author/navi.phtml'); ?>
|
||||
</div>
|
||||
<div class="span9">
|
||||
<div>
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active"><a href="/author/doi">浏览所有</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
<div class="input-append">
|
||||
<form id="datasearch" class="search_form" action="">
|
||||
<input type="text" id="keyword" name="q" value="<?php if(!empty($this->q)) echo $this->q; ?>" />
|
||||
<button type="submit" class="btn" id="search_btn">搜索</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php if(!empty($this->error)) { ?>
|
||||
<?= $this->error ?>
|
||||
<?php } ?>
|
||||
<?php if(!empty($this->msg)) { ?>
|
||||
<?= $this->msg ?>
|
||||
<?php } else{ ?>
|
||||
<div id="datalist">
|
||||
<?php if (count($this->paginator)): ?>
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>UUID</th>
|
||||
<th>元数据</th>
|
||||
<th>DOI</th>
|
||||
<th width="70">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php $autoindex=0;
|
||||
foreach ($this->paginator as $item):
|
||||
$autoindex++;?>
|
||||
<tr id="DataLine_<?= $item['id']?>">
|
||||
<td><?= $item['uuid'] ?></td>
|
||||
<td><?= $item['title'] ?></td>
|
||||
<td><?= $item['doi'] ?></td>
|
||||
<td>
|
||||
<a href="/author/doi/ac/edit/uuid/<?= $item['uuid']?>">编辑</a>
|
||||
<a href="javascript:void(0);" onclick="onedel(<?= $item['id']?>)" id="delbtn_<?= $item['id']?>">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
<div class="pagenavi"><?= $this->paginator; ?></div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<!-- //页面内容 -->
|
||||
<script>
|
||||
var info = {
|
||||
btn_prefix : "delbtn_",
|
||||
item_prefix : "DataLine_",
|
||||
url : "/author/doi/ac/del"
|
||||
}
|
||||
</script>
|
|
@ -10,7 +10,8 @@
|
|||
<li id="Nav-author-document"><a href="/author/document"><i class="icon-chevron-right"></i>数据文档管理</a></li>
|
||||
<li id="Nav-author-news"><a href="/author/news"><i class="icon-chevron-right"></i>数据新闻管理</a></li>
|
||||
<li id="Nav-author-version"><a href="/author/version"><i class="icon-chevron-right"></i>数据版本管理</a></li>
|
||||
<li id="Nav-author-version"><a href="/author/fund"><i class="icon-chevron-right"></i>支持项目</a></li>
|
||||
<li id="Nav-author-fund"><a href="/author/fund"><i class="icon-chevron-right"></i>支持项目</a></li>
|
||||
<li id="Nav-author-doi"><a href="/author/doi"><i class="icon-chevron-right"></i>DOI</a></li>
|
||||
<!--
|
||||
<li><a href="/author/survey">数据调查</a></li>
|
||||
<li><a href="/author/qa">数据QA</a></li> -->
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
class Author extends Zend_Controller_Plugin_Abstract
|
||||
{
|
||||
private $db; //传入PDO对象.
|
||||
private $auth = NULL; //Zend_Auth 对象
|
||||
|
||||
//使用到的公共变量
|
||||
public $tbl_metadata = "metadata"; //元数据
|
||||
public $tbl_author = "mdauthor"; //数据作者表
|
||||
|
||||
function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
//检查前台用户对某条数据的权限
|
||||
function checkAuthor($uuid,$uid=0)
|
||||
{
|
||||
if(empty($uid))
|
||||
{
|
||||
$auth = Zend_Auth::getInstance();
|
||||
if($auth->hasIdentity())
|
||||
{
|
||||
$user = $auth->getIdentity();
|
||||
$uid = $user->id;
|
||||
}
|
||||
}
|
||||
if(!empty($uid))
|
||||
{
|
||||
$sql = "SELECT * FROM ".$this->tbl_author." WHERE uuid='$uuid' AND userid=$uid";
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
$rs = $this->db->query($sql);
|
||||
$row = $rs->fetch(PDO::FETCH_BOTH);
|
||||
if($row['status']>0)
|
||||
{
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,9 +12,18 @@ class Doi extends Zend_Controller_Plugin_Abstract
|
|||
$this->db = $db;
|
||||
}
|
||||
|
||||
function fetch()
|
||||
function fetch($uid=0)
|
||||
{
|
||||
if(empty($uid))
|
||||
{
|
||||
$sql = "SELECT * FROM ".$this->tbl_doi." ORDER BY id DESC";
|
||||
}else{
|
||||
$sql = "SELECT doi.* FROM ".$this->tbl_doi." doi
|
||||
LEFT JOIN mdauthor a ON doi.uuid=a.uuid
|
||||
WHERE a.userid=".$uid." AND a.status>0
|
||||
ORDER BY id DESC
|
||||
";
|
||||
}
|
||||
$rs = $this->db->query($sql);
|
||||
$rows = $rs->fetchAll();
|
||||
return $rows;
|
||||
|
@ -29,7 +38,13 @@ class Doi extends Zend_Controller_Plugin_Abstract
|
|||
return $dbh->insert($this->tbl_doi,$data);
|
||||
}
|
||||
|
||||
function update($data,$uuid){
|
||||
function update($data,$uuid,$uid=0){
|
||||
include_once("data/Author.php");
|
||||
$author = new Author($this->db);
|
||||
if($author->checkAuthor($uuid,$uid)==false)
|
||||
{
|
||||
return "您没有权限";
|
||||
}
|
||||
$doi_info = $this->view($uuid);
|
||||
if($doi_info == false)
|
||||
{
|
||||
|
@ -85,7 +100,7 @@ class Doi extends Zend_Controller_Plugin_Abstract
|
|||
$info[$k] = array(
|
||||
'author'=>$authors[$k],
|
||||
'organization'=>$orgs[$k],
|
||||
'order'=>0
|
||||
'order'=> 5*count($authors)-($k*5)
|
||||
);
|
||||
}
|
||||
//include_once("helper/view.php");
|
||||
|
@ -106,14 +121,33 @@ class Doi extends Zend_Controller_Plugin_Abstract
|
|||
return $row;
|
||||
}
|
||||
|
||||
function delete($id){
|
||||
function delete($id,$uid=0){
|
||||
if(!is_numeric($id))
|
||||
{
|
||||
return "参数错误";
|
||||
}
|
||||
if($uid != 0){
|
||||
$sql = "SELECT uuid FROM ".$this->tbl_doi." WHERE id=$id";
|
||||
$rs = $this->db->query($sql);
|
||||
$row = $rs->fetch();
|
||||
if(isset($row['uuid']) && !empty($row['uuid'])){
|
||||
include_once("data/Author.php");
|
||||
$author = new Author($this->db);
|
||||
if($author->checkAuthor($row['uuid'],$uid)==false)
|
||||
{
|
||||
return "您没有权限";
|
||||
}
|
||||
$condition = " id=$id ";
|
||||
$sql = "DELETE FROM ".$this->tbl_doi." WHERE $condition";
|
||||
return $this->db->exec($sql);
|
||||
}else{
|
||||
return "该记录不存在";
|
||||
}
|
||||
}else{
|
||||
$condition = " id=$id ";
|
||||
$sql = "DELETE FROM ".$this->tbl_doi." WHERE $condition";
|
||||
return $this->db->exec($sql);
|
||||
}
|
||||
}
|
||||
|
||||
function _getParams(Zend_Controller_Request_Abstract $request)
|
||||
|
|
Loading…
Reference in New Issue