修改作者功能

This commit is contained in:
wlx 2014-09-02 13:06:15 +00:00
parent 30635d3be2
commit e26f395965
4 changed files with 167 additions and 79 deletions

View File

@ -1622,8 +1622,8 @@ class AuthorController extends Zend_Controller_Action
if (!empty($uuid) && empty($ac))
{
//view the versions of the data
$sql = "SELECT md.title,md.uuid,v.ts_created,v.changelog,v.userid,v.id,u.username,u.realname FROM mdversion v
LEFT JOIN metadata md ON md.uuid=v.uuid
$sql = "SELECT md.title,md.uuid,v.ts_created,v.changelog,v.userid,v.id,u.username,u.realname FROM en.mdversion v
LEFT JOIN en.metadata md ON md.uuid=v.uuid
LEFT JOIN mdauthor a ON md.uuid=a.uuid
left join users u on v.userid=u.id
WHERE md.title IS NOT NULL AND a.userid=? and v.uuid=? AND a.status=1
@ -1645,8 +1645,8 @@ class AuthorController extends Zend_Controller_Action
//查看所有版本列表
else if((empty($ac) && empty($uuid))|| $ac=='list')
{
$sql = "SELECT md.title,md.uuid,v.ts_created,v.changelog,v.userid,v.id,u.username,u.realname FROM mdversion v
LEFT JOIN metadata md ON md.uuid=v.uuid
$sql = "SELECT md.title,md.uuid,v.ts_created,v.changelog,v.userid,v.id,u.username,u.realname FROM en.mdversion v
LEFT JOIN en.metadata md ON md.uuid=v.uuid
LEFT JOIN mdauthor a ON md.uuid=a.uuid
left join users u on v.userid=u.id
WHERE md.title IS NOT NULL AND a.userid=? AND a.status=1
@ -1671,8 +1671,8 @@ class AuthorController extends Zend_Controller_Action
$keywords = $this->_request->getParam('q');
if(!empty($keywords))
$this->view->q = $keywords;
$sql = "SELECT md.title,md.uuid,count(v.id) as c FROM mdversion v
LEFT JOIN metadata md ON md.uuid=v.uuid
$sql = "SELECT md.title,md.uuid,count(v.id) as c FROM en.mdversion v
LEFT JOIN en.metadata md ON md.uuid=v.uuid
LEFT JOIN mdauthor a ON md.uuid=a.uuid
WHERE md.title IS NOT NULL AND a.userid=? AND a.status=1";
if(!empty($keywords))
@ -1715,7 +1715,7 @@ class AuthorController extends Zend_Controller_Action
return true;
}
$sql = "DELETE FROM mdversion v
$sql = "DELETE FROM en.mdversion v
USING mdauthor a
WHERE v.uuid=a.uuid and v.id=? AND a.userid=? AND a.status=1";
$sth = $this->db->prepare($sql);
@ -1758,7 +1758,7 @@ class AuthorController extends Zend_Controller_Action
}
$this->wdb=Zend_Db::factory($this->view->config->geonetwork);
$sql = "SELECT v.xml,v.uuid FROM mdversion v
$sql = "SELECT v.xml,v.uuid FROM en.mdversion v
LEFT JOIN mdauthor a ON a.uuid=v.uuid
WHERE v.id=? AND a.userid=? AND a.status=1";
$sth = $this->db->prepare($sql);
@ -1826,7 +1826,7 @@ class AuthorController extends Zend_Controller_Action
}
// 1. 权限认定
$sql="select a.* from mdauthor a left join mdversion v on a.uuid=v.uuid
$sql="select a.* from mdauthor a left join en.mdversion v on a.uuid=v.uuid
where a.status=1 and a.userid=? and v.id=?";
$sth=$this->db->prepare($sql);
$sth->execute(array($u_id,$id));
@ -1838,11 +1838,11 @@ class AuthorController extends Zend_Controller_Action
return true;
}
// 2. 保存变化记录 save changelog & userid
$sql = "UPDATE mdversion SET changelog=?,userid=? WHERE id=?";
$sql = "UPDATE en.mdversion SET changelog=?,userid=? WHERE id=?";
$this->db->query($sql,array($changelog,$u_id,$id));
// 3. 获取数据评审状态
$sql = "SELECT s.*,v.xml,m.title FROM mdstatus s left join mdversion v on s.uuid=v.uuid
$sql = "SELECT s.*,v.xml,m.title FROM en.mdstatus s left join mdversion v on s.uuid=v.uuid
left join metadata m on s.uuid=m.uuid WHERE v.id=?";
$sth = $this->db->prepare($sql);
$sth->execute(array($id));
@ -1852,7 +1852,7 @@ class AuthorController extends Zend_Controller_Action
$search=new Search();
//create search view in xunsearch
//$sql="select m.uuid,m.title,m.description,x.data,array_to_string(ARRAY( SELECT keyword.keyword FROM keyword WHERE keyword.id = m.id), ', '::text) AS keyword from normalmetadata m left join xml x on m.id=x.id where m.uuid=?";
$sql="select * from xunsearch where uuid=?";
$sql="select * from en.xunsearch where uuid=?";
$sth = $this->db->prepare($sql);
$sth->execute(array($row['uuid']));
$data = $sth->fetch();
@ -1860,7 +1860,7 @@ class AuthorController extends Zend_Controller_Action
if (empty($row)) //无对应记录
{
$sql="select m.id from metadata m left join mdversion v on m.uuid=v.uuid where v.id=?";
$sql="select m.id from en.metadata m left join en.mdversion v on m.uuid=v.uuid where v.id=?";
$sth=$this->db->prepare($sql);
$sth->execute(array($id));
$mrow=$sth->fetch();
@ -1877,13 +1877,13 @@ class AuthorController extends Zend_Controller_Action
}
@$iso->saveDB($this->db);
//进入评审库
$sql="insert into mdstatus (uuid,status,userid) select uuid,0,? from mdversion where id=?";
$sql="insert into en.mdstatus (uuid,status,userid) select uuid,0,? from en.mdversion where id=?";
$this->db->query($sql,array($u_id,$id));
//email to admin
$mail=new WestdcMailer($this->view->config->smtp);
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
$mailtp=new EmailText($this->db,"metadata-new-admin",array(
$mail->setFrom($this->view->config->service->email,'CARD Support Team');
$mailtp=new EmailText($this->db,"metadata-new-admin-en",array(
'user' => $user->username,
'uuid' => $iso->uuid,
'email'=> $user->email,
@ -1905,7 +1905,7 @@ class AuthorController extends Zend_Controller_Action
//email to author
$mail=new WestdcMailer($this->view->config->smtp);
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
$mailtp=new EmailText($this->db,"metadata-new-author",array(
$mailtp=new EmailText($this->db,"metadata-new-author-en",array(
'user' => $user->username,
'uuid' => $iso->uuid,
'email'=> $user->email,
@ -1939,15 +1939,15 @@ class AuthorController extends Zend_Controller_Action
@$iso->saveDB($this->db);
//移除中间版本
$sql="delete from mdversion where uuid in (select uuid from mdversion where id=?) and changelog is null";
$sql="delete from en.mdversion where uuid in (select uuid from en.mdversion where id=?) and changelog is null";
$this->db->query($sql,array($id));
//修改评审状态为发布,且由其提交的用户进行管理
$sql="insert into mdstatus (uuid,status,userid) select uuid,6,? from mdversion where id=?";
$sql="insert into en.mdstatus (uuid,status,userid) select uuid,6,? from en.mdversion where id=?";
$this->db->query($sql,array($u_id,$id));
//email to admin & author
$mail=new WestdcMailer($this->view->config->smtp);
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
$mail->setFrom($this->view->config->service->email,'CARD Support Team');
$mailtp=new EmailText($this->db,"metadata-release",array(
'user' => $user->username,
'uuid' => $row['uuid'],
@ -1987,7 +1987,7 @@ class AuthorController extends Zend_Controller_Action
//email to admin
$mail=new WestdcMailer($this->view->config->smtp);
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
$mail->setFrom($this->view->config->service->email,'CARD Support Team');
$mailtp=new EmailText($this->db,"version-commit-admin",array(
'user' => $user->username,
'uuid' => $row['uuid'],
@ -2010,7 +2010,7 @@ class AuthorController extends Zend_Controller_Action
unset($mailtp);
//email to author
$mail=new WestdcMailer($this->view->config->smtp);
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
$mail->setFrom($this->view->config->service->email,'CARD Support Team');
$mailtp=new EmailText($this->db,"version-commit-author",array(
'user' => $user->username,
'uuid' => $row['uuid'],
@ -2040,7 +2040,7 @@ class AuthorController extends Zend_Controller_Action
@$iso->loadXML($row['xml']);
//email to admin
$mail=new WestdcMailer($this->view->config->smtp);
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
$mail->setFrom($this->view->config->service->email,'CARD Support Team');
$mailtp=new EmailText($this->db,"version-commit-admin",array(
'user' => $user->username,
'uuid' => $row['uuid'],
@ -2063,7 +2063,7 @@ class AuthorController extends Zend_Controller_Action
unset($mailtp);
//email to author
$mail=new WestdcMailer($this->view->config->smtp);
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
$mail->setFrom($this->view->config->service->email,'CARD Support Team');
$mailtp=new EmailText($this->db,"version-commit-author",array(
'user' => $user->username,
'uuid' => $row['uuid'],
@ -2091,7 +2091,7 @@ class AuthorController extends Zend_Controller_Action
unset($mail);
unset($mailtp);
$mail=new WestdcMailer($this->view->config->smtp);
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
$mail->setFrom($this->view->config->service->email,'CARD Support Team');
$mailtp=new EmailText($this->db,"version-commit-expert",array(
'user' => $user->username,
'uuid' => $row['uuid'],
@ -2132,12 +2132,12 @@ class AuthorController extends Zend_Controller_Action
@$iso->saveDB($this->db);
//移除中间版本
$sql="delete from mdversion where uuid in (select uuid from mdversion where id=?) and changelog is null";
$sql="delete from en.mdversion where uuid in (select uuid from en.mdversion where id=?) and changelog is null";
$this->db->query($sql,array($id));
//email to admin & author
$mail=new WestdcMailer($this->view->config->smtp);
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
$mail->setFrom($this->view->config->service->email,'CARD Support Team');
$mailtp=new EmailText($this->db,"metadata-release",array(
'user' => $user->username,
'uuid' => $row['uuid'],
@ -2183,16 +2183,16 @@ class AuthorController extends Zend_Controller_Action
return true;
}
$sql = "SELECT v.uuid,md.title FROM mdversion v
$sql = "SELECT v.uuid,md.title FROM en.mdversion v
LEFT JOIN mdauthor a ON a.uuid=v.uuid
LEFT JOIN metadata md ON v.uuid=md.uuid
LEFT JOIN en.metadata md ON v.uuid=md.uuid
WHERE v.id=? AND a.userid=? AND a.status=1";
$sth = $this->db->prepare($sql);
$sth -> execute(array($id,$u_id));
$row = $sth->fetch();
$sql = "SELECT v.* FROM mdversion v
$sql = "SELECT v.* FROM en.mdversion v
WHERE v.uuid=? AND v.id<=?
ORDER BY v.ts_created DESC
LIMIT ?";
@ -2723,6 +2723,122 @@ class AuthorController extends Zend_Controller_Action
}
}
//查看单条文献的所有数据
if (!empty($id) && empty($ac))
{
$sql = "SELECT md.title,md.uuid,r.id,r.reference,r.link,(a.userid-?) as isauthor FROM mdref mr
LEFT JOIN en.metadata md ON md.uuid=mr.uuid
LEFT JOIN mdauthor a ON md.uuid=a.uuid
left join reference r on mr.refid=r.id
WHERE md.title IS NOT NULL AND mr.refid=? AND a.status=1
order by md.ts_created desc
";
$sth = $this->db->prepare($sql);
$sth->execute(array($u_id,$id));
$rows = $sth->fetchAll();
@$this->view->mdtitle=$rows[0]['reference'];
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(15);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
$this->_helper->viewRenderer('literature-viewliter');
}
//查看所有文献列表
else if((empty($ac) && empty($uuid)) && empty($id))
{
$keywords = $this->_request->getParam('q');
$sql = "SELECT md.title,md.uuid,r.reference,r.id,mr.id as mrid FROM mdref mr
LEFT JOIN en.metadata md ON md.uuid=mr.uuid
LEFT JOIN mdauthor a ON md.uuid=a.uuid
left join reference r on mr.refid=r.id
WHERE md.title IS NOT NULL AND a.userid=? AND a.status=1";
if(!empty($keywords))
$this->view->q = $keywords;
if(!empty($keywords))
{
$search=new SimpleSearch($keywords);
$where=$search->sql_expr(array("r.reference","md.title","md.description"));
$sql.=' and '.$where;
}
$sql.=" order by md.ts_created desc";
$sth = $this->db->prepare($sql);
$sth->execute(array($u_id));
$rows = $sth->fetchAll();
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(15);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
}
//按文献浏览
else if($ac=="byliter")
{
$keywords = $this->_request->getParam('q');
if(!empty($keywords))
$this->view->q = $keywords;
$sql = "SELECT count(md.uuid) as c,r.reference,r.id FROM reference r
left join mdref mr on r.id=mr.refid
LEFT JOIN en.metadata md ON md.uuid=mr.uuid
LEFT JOIN mdauthor a ON md.uuid=a.uuid
WHERE md.title IS NOT NULL AND a.userid=? AND a.status=1";
if(!empty($keywords))
{
$search=new SimpleSearch($keywords);
$where=$search->sql_expr(array("r.reference"));
$sql.=' and '.$where;
}
$sql.=" group by r.reference,r.id";
$sth = $this->db->prepare($sql);
$sth->execute(array($u_id));
$rows = $sth->fetchAll();
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(10);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
$this->_helper->viewRenderer('literature-byliter');
}
//单条文献的信息
else if ($ac == "get")
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$id = $this->_getParam('id');
$data = $author->Literature->getOne($id);
$this->jsonexit($data);
return true;
}
//按数据浏览
else if($ac=="bydata")
{
$keywords = $this->_request->getParam('q');
if(!empty($keywords))
{
$lit = $author->Literature->bydata($keywords);
$this->view->q = $keywords;
}else{
$lit = $author->Literature->bydata();
}
view::addPaginator($lit,$this->view,$this->_request);
$this->_helper->viewRenderer('literature-bydata');
}
//添加文献信息
else if($ac == "add")
{

View File

@ -4,9 +4,9 @@ $this->headTitle($this->config->title->author);
$this->headTitle()->setSeparator(' - ');
$this->theme->AppendPlus($this,'colorbox');
$this->headLink()->appendStylesheet('/css/author.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/author">数据作者</a>');
$this->breadcrumb('我的数据');
$this->breadcrumb('<a href="/">Home</a>');
$this->breadcrumb('<a href="/author">Author</a>');
$this->breadcrumb('My datasets');
$this->breadcrumb()->setSeparator(' > ');
?>
<div class="row">
@ -14,12 +14,10 @@ $this->breadcrumb()->setSeparator(' > ');
<?= $this->partial('author/navi.phtml'); ?>
</div>
<div class="span9">
<p>请输入元数据标题关键字进行搜索</p>
<div class="input-append">
<form id="datasearch" class="search_form" action="/author/accept/ac/search">
<input class="span2" type="text" id="keyword" name="q" value="<?php if(!empty($this->q)) echo $this->q; ?>">
<button class="btn" type="submit">搜索</button>
<input class="span2" type="text" id="keyword" name="q" placeholder="Search in title" value="<?php if(!empty($this->q)) echo $this->q; ?>">
<button class="btn" type="submit">Search</button>
</form>
</div>
<div>
@ -32,26 +30,13 @@ $this->breadcrumb()->setSeparator(' > ');
<li class="well">
<h4><a href="/data/<?php echo $item['uuid'];?>" target="_blank" class="title"><?php echo $item['title'];?></a></h4>
<?php if($item['status']==1) : ?>
<span class="dtctrlplan">【操作:
<a href="/author/inauthor/ac/datalist/uuid/<?php echo $item['uuid']; ?>">申请管理</a> |
<a href="/author/comment/ac/view/uuid/<?php echo $item['uuid']; ?>">反馈</a> |
<a href="/author/document/uuid/<?php echo $item['uuid']; ?>">文档</a> |
<a href="/author/literature/uuid/<?php echo $item['uuid']; ?>">文献</a> |
<a href="/author/literature/ac/add/uuid/<?php echo $item['uuid']; ?>" class="more iframe">添加文献</a> |
<a href="/service/geonetwork?url=metadata.edit?id=<?php echo $item['gid']; ?>" target="_blank">修改元数据</a> |
<a href="/author/version/uuid/<?php echo $item['uuid']; ?>">版本</a> |
<a href="/author/qa/uuid/<?php echo $item['uuid']; ?>">QA</a> |
<a href="/author/news/uuid/<?php echo $item['uuid']; ?>">新闻</a> |
<a href="/author/viewauthors/uuid/<?php echo $item['uuid']; ?>">所有作者</a>
<?php if($item['mdstatus']==6) {?>
| <a href="/author/delegate/uuid/<?php echo $item['uuid'];?>" onclick="return confirm('是否确定将该数据委托至数据中心?');">委托</a>
<?php } if($item['mdstatus']==7){ ?>
| <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/uuid/<?php echo $item['uuid']; ?>">支持项目</a> |
<a href="/author/doi/ac/edit/uuid/<?php echo $item['uuid']; ?>">DOI</a>
<span class="dtctrlplan"> [
<a href="/service/geonetwork?url=metadata.edit?id=<?php echo $item['gid']; ?>" target="_blank">Edit metadata</a> |
<a href="/author/literature/uuid/<?php echo $item['uuid']; ?>">Literatures</a> |
<a href="/author/literature/ac/add/uuid/<?php echo $item['uuid']; ?>" class="more iframe">Add new literature</a> |
<a href="/author/version/uuid/<?php echo $item['uuid']; ?>">Versions</a>
]
</span>
<?php endif; ?>

View File

@ -3,20 +3,7 @@
<li id="Nav-author-index"><a href="/author/"><i class="icon-chevron-right"></i>Introduce</a></li>
<li id="Nav-author-newdata"><a href="/author/newdata"><i class="icon-chevron-right"></i>Submit data</a></li>
<li id="Nav-author-accept"><a href="/author/accept"><i class="icon-chevron-right"></i>My datasets</a></li>
<!--
<li id="Nav-author-apply"><a href="/author/apply"><i class="icon-chevron-right"></i>数据认证</a></li>
<li id="Nav-author-inauthor"><a href="/author/inauthor"><i class="icon-chevron-right"></i>数据申请管理</a></li>
<li id="Nav-author-comment"><a href="/author/comment"><i class="icon-chevron-right"></i>数据反馈管理</a></li> -->
<li id="Nav-author-literature"><a href="/author/literature"><i class="icon-chevron-right"></i>Data publications</a></li>
<li id="Nav-author-document"><a href="/author/document"><i class="icon-chevron-right"></i>Data document</a></li>
<li id="Nav-author-news"><a href="/author/news"><i class="icon-chevron-right"></i>Data news</a></li>
<li id="Nav-author-version"><a href="/author/version"><i class="icon-chevron-right"></i>Data versions</a></li>
<!--
<li id="Nav-author-doi"><a href="/author/doi"><i class="icon-chevron-right"></i>DOI</a></li>
<li id="Nav-author-fund"><a href="/author/fund/ac/data"><i class="icon-chevron-right"></i>支持项目</a></li>
<li><a href="/author/survey">数据调查</a></li>
<li><a href="/author/qa">数据QA</a></li>
<li id="Nav-author-statics"><a href="/author/statics"><i class="icon-chevron-right"></i>信息统计</a></li>
-->
<li id="Nav-author-literature"><a href="/author/literature"><i class="icon-chevron-right"></i>Literatures</a></li>
<li id="Nav-author-version"><a href="/author/version"><i class="icon-chevron-right"></i>Versions</a></li>
</ul>
</div>

View File

@ -5,7 +5,7 @@ class Author extends Zend_Controller_Plugin_Abstract
private $auth = NULL; //Zend_Auth 对象
//使用到的公共变量
public $tbl_metadata = "metadata"; //元数据
public $tbl_metadata = "en.metadata"; //元数据
public $tbl_author = "mdauthor"; //数据作者表
public $tbl_user = "users";
@ -86,7 +86,7 @@ class Literature extends Author
include_once("helper/view.php");
$uid = view::User('id');
$sql = "SELECT md.title,md.uuid,r.id,r.reference,r.link,mr.place,mr.id as mrid FROM mdref mr
LEFT JOIN metadata md ON md.uuid=mr.uuid
LEFT JOIN en.metadata md ON md.uuid=mr.uuid
LEFT JOIN mdauthor a ON md.uuid=a.uuid
left join reference r on mr.refid=r.id
WHERE md.title IS NOT NULL AND a.userid=? and mr.uuid=? AND a.status=1
@ -149,7 +149,7 @@ class Literature extends Author
return false;
}
$sql = "SELECT md.title,md.uuid,count(mr.id) as c FROM metadata md
$sql = "SELECT md.title,md.uuid,count(mr.id) as c FROM en.metadata md
LEFT JOIN mdref mr ON md.uuid=mr.uuid
LEFT JOIN mdauthor a ON md.uuid=a.uuid
left join reference r on mr.refid=r.id