修复数据上传路径问题,添加未提交数据功能

This commit is contained in:
wlx 2012-04-21 12:39:35 +00:00
parent 09c028b8e3
commit 618288b2b3
6 changed files with 294 additions and 180 deletions

View File

@ -3,44 +3,24 @@ class SubmitController extends Zend_Controller_Action
{
private $limit=10;
//调试模式
// 调试模式中将显示全部错误细节,电子邮件将发往调试邮箱
// 1 为开启
// 0 为关闭
public $debug = 1;
//调试模式邮箱地址
public $debug_email = "la5c@qq.com";
function preDispatch()
{
$this->view->config = Zend_Registry::get('config');
$this->db=Zend_Registry::get('db');
$this->messenger=$this->_helper->getHelper('FlashMessenger');
$this->view->messages = $this->messenger->getMessages();
}
function indexAction()
{
}
/*
* helpAction() 帮助文档
*
*/
function helpAction(){
}//helpAction()帮助文档
//新建元数据
function newdataAction()
{
$ac = $this->_request->getParam('ac');
$id = $this->_request->getParam('id');
$this->wdb=Zend_Db::factory($this->view->config->geonetwork);
//新建元数据
function newdataAction()
{
$ac = $this->_request->getParam('ac');
$id = $this->_request->getParam('id');
$this->wdb=Zend_Db::factory($this->view->config->geonetwork);
$auth = Zend_Auth::getInstance();
$auth = Zend_Auth::getInstance();
if($auth->hasIdentity())
{
$user = $auth->getIdentity();
@ -108,148 +88,164 @@ class SubmitController extends Zend_Controller_Action
$this->view->templates=$sth->fetchAll();
$this->_helper->viewRenderer('newdata-add');
}
//提交数据
else if($ac=="commit")
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$data = "";
try{
$id = $this->_request->getParam('id');
if(empty($id) || !is_numeric($id))
{
$data = array("error"=>"参数错误");
$this->jsonexit($data);
return true;
}
$changelog = $this->_request->getParam('changelog');
if(empty($changelog))
{
$data = array("error"=>$this->alertbox('warning','请输入变更信息'));
$this->jsonexit($data);
return true;
}
// 1. 权限认定当前用户必须和其owner相同
// 数据应当没有评审状态,没有作者信息
$sql="select gn.id from geonetworkmetadata gn
left join mdstatus s on gn.uuid=s.uuid
left join mdauthor a on s.uuid=a.uuid
where s.id is not null and a.id is not null and gn.id=?";
$sth=$this->db->prepare($sql);
$sth->execute(array($id));
$row=$sth->fetch();
if (!emtpy($row))
{
$data = array("error"=>'错误的入口');
$this->jsonexit($data);
return true;
}
$sql="select uuid from metadata where id=? and owner=?";
$sth=$this->wdb->prepare($sql);
$sth->execute(array($id,$u_id));
$row=$sth->fetch();
if (empty($row))
{
$data = array("error"=>'无权限修改数据');
$this->jsonexit($data);
return true;
}
// 保存数据作者信息
$sql="insert into mdauthor (uuid,userid,ts_activated,status) values(?,?,now(),1)";
$sth=$this->db->query($sql,array($row['uuid'],$u_id));
// 2. 保存变化记录 save changelog & userid for the latest version
$sql = "UPDATE mdversion SET changelog=?,userid=? WHERE id in (select id from mdversion where uuid=? order by ts_created desc limit 1)";
$this->db->query($sql,array($changelog,$u_id,$row['uuid']));
// 3. 保存数据评审状态
//导入元数据
$iso=new ISO19115();
$iso->saveDB($this->db,$row['xml']);
//进入评审库
$sql="insert into mdstatus (uuid,status,userid) select uuid,0,? from 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(
'user' => $user->username,
'uuid' => $iso->uuid,
'email'=> $user->email,
//元数据标题
'title'=> $iso->resTitle,
));
$mail->setBodyText($mailtp->getBody());
$mail->setSubject($mailtp->getSubject());
if($this->debug==0)
{
$mail->addTo($this->view->config->service->email);
}else{
$mail->addTo($this->debug_email);
}
$mail->send();
unset($mail);
unset($mailtp);
//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(
'user' => $user->username,
'uuid' => $iso->uuid,
'email'=> $user->email,
//元数据标题
'title'=> $iso->resTitle,
));
$mail->setBodyText($mailtp->getBody());
$mail->setSubject($mailtp->getSubject());
if($this->debug==0)
{
$mail->addTo($user->email);
$mail->addCc($this->view->config->service->email);
}else{
$mail->addTo($this->debug_email);
}
@$mail->send();
$data = array("commited"=>1,"error"=>$this->alertbox('ok','该版本已经成功提交,请等待数据中心进一步处理!'));
$this->jsonexit($data);
return true;
}catch(Exception $e) {
$msg = "提交失败,请确认权限后重试";
if($this->debug>0)
{$msg .= $e->getMessage();}
$data = array("error"=>$this->alertbox('error',$msg));
$this->jsonexit($data);
return true;
}
}
}
function uploadAction(){
//未提交数据列表
function unsubmitAction()
{
$ac = $this->_request->getParam('ac');
$id = $this->_request->getParam('id');
$this->wdb=Zend_Db::factory($this->view->config->geonetwork);
$auth = Zend_Auth::getInstance();
if($auth->hasIdentity())
{
$user = $auth->getIdentity();
$u_id = $user->id;
}
//提交数据
if($ac=="commit")
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$data = "";
try{
$id = $this->_request->getParam('id');
if(empty($id) || !is_numeric($id))
{
$data = array("error"=>"参数错误");
$this->jsonexit($data);
return true;
}
$changelog = $this->_request->getParam('changelog');
if(empty($changelog))
{
$data = array("error"=>$this->alertbox('warning','请输入变更信息'));
$this->jsonexit($data);
return true;
}
// 1. 权限认定当前用户必须和其owner相同
// 数据应当没有评审状态,没有作者信息
$sql="select gn.id from geonetworkmetadata gn
left join mdstatus s on gn.uuid=s.uuid
left join mdauthor a on s.uuid=a.uuid
where s.id is not null and a.id is not null and gn.id=?";
$sth=$this->db->prepare($sql);
$sth->execute(array($id));
$row=$sth->fetch();
if (!emtpy($row))
{
$data = array("error"=>'错误的入口');
$this->jsonexit($data);
return true;
}
$sql="select uuid from metadata where id=? and owner=?";
$sth=$this->wdb->prepare($sql);
$sth->execute(array($id,$u_id));
$row=$sth->fetch();
if (empty($row))
{
$data = array("error"=>'无权限修改数据');
$this->jsonexit($data);
return true;
}
// 保存数据作者信息
$sql="insert into mdauthor (uuid,userid,ts_activated,status) values(?,?,now(),1)";
$sth=$this->db->query($sql,array($row['uuid'],$u_id));
// 2. 保存变化记录 save changelog & userid for the latest version
$sql = "UPDATE mdversion SET changelog=?,userid=? WHERE id in (select id from mdversion where uuid=? order by ts_created desc limit 1)";
$this->db->query($sql,array($changelog,$u_id,$row['uuid']));
// 3. 保存数据评审状态
//导入元数据
$iso=new ISO19115();
$iso->saveDB($this->db,$row['xml']);
//进入评审库
$sql="insert into mdstatus (uuid,status,userid) select uuid,0,? from 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(
'user' => $user->username,
'uuid' => $iso->uuid,
'email'=> $user->email,
//元数据标题
'title'=> $iso->resTitle,
));
$mail->setBodyText($mailtp->getBody());
$mail->setSubject($mailtp->getSubject());
$mail->addTo($this->view->config->service->email);
$mail->send();
unset($mail);
unset($mailtp);
//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(
'user' => $user->username,
'uuid' => $iso->uuid,
'email'=> $user->email,
//元数据标题
'title'=> $iso->resTitle,
));
$mail->setBodyText($mailtp->getBody());
$mail->setSubject($mailtp->getSubject());
$mail->addTo($user->email);
$mail->addCc($this->view->config->service->email);
@$mail->send();
$data = array("commited"=>1,"error"=>$this->alertbox('ok','该版本已经成功提交,请等待数据中心进一步处理!'));
$this->jsonexit($data);
return true;
}catch(Exception $e) {
$msg = "提交失败,请确认权限后重试";
if($this->debug>0)
{$msg .= $e->getMessage();}
$data = array("error"=>$this->alertbox('error',$msg));
$this->jsonexit($data);
return true;
}
}
else
{
$sql = "SELECT (regexp_matches(gn.data,'<resTitle>(.*)</resTitle>'))[1] as title,gn.id,gn.uuid FROM geonetworkmetadata gn
WHERE gn.uuid not in (select uuid from metadata) and gn.owner=?
order by gn.id 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;
}
}
function uploadAction()
{
$this->_helper->layout()->disableLayout();
$uuid = $this->_request->getParam('uuid');
$this->view->uuid=$uuid;
$ac = $this->_request->getParam('ac');
$dataFilePath = "../data/";
$dataFilePath = "../data/upload/";
if($ac=='submit')
{
$this->_helper->viewRenderer->setNoRender();
$this->_helper->viewRenderer->setNoRender();
$auth = Zend_Auth::getInstance();
if($auth->hasIdentity())
{
@ -285,10 +281,6 @@ class SubmitController extends Zend_Controller_Action
$data = array("error"=>'数据文件保存成功');
$this->jsonexit($data);
return true;
}

View File

@ -21,29 +21,51 @@ $this->breadcrumb()->setSeparator(' > ');
<div class="helplist">
<ul>
<li id="author_system">
<h1>数据作者系统有什么功能?</h1>
<h1>数据汇交有什么功能?</h1>
<div class="content">
<p>1、进行数据认证</p>
<p>您在数据中心发布了一条数据,若需对数据进行修改,则需要进行数据认证。</p>
<p>数据汇交的流程</p>
<p>您需要先新建元数据,然后根据对应的元数据上传数据,上传数据后即可提交审核,具体流程可参见下图。</p>
<img src="/images/submit.png" />
</div>
</li>
<li id="help_apply">
<h1>如何成为已发布数据的作者</h1>
<h1>为何要新建元数据</h1>
<div class="content">
<p>登录后,进入网站的“数据作者”→“数据认证”页面,在搜索框内输入您的数据的关键字,然后点击搜索,带列表加载后,点击数据介绍下方的“申请成为此数据的作者”即可进入申请步骤。该功能需要登录后使用(<a href="/author/apply">点击这里</a>可以进入数据认证)</p>
<p>元数据是描述数据的数据,为了让用户能快速、准确的了解您提供的数据,我们需要您提供该数据对应的元数据。在新建元数据时,需要用户先登陆。(<a href="/submit/newdata">点击这里</a>可以新建元数据)</p>
</div>
</li>
<li id="help_inauthor">
<h1>在线、离线数据查看与审批功能</h1>
<h1>如何创建元数据?</h1>
<div class="content">
<p>1.在线数据申请记录查看:</p>
<p>点击网站主导航"数据作者",进入数据作者页面后,点击左侧导航栏的"数据申请管理"。默认进入在线数据申请记录页面,在线数据申请不需要审批,用户可直接下载。该功能需要登录后使用(<a href="/author/inauthor/ac/online">点击这里</a>可以进入在线申请记录)</p>
<p>2.离线数据申请记录查看:</p>
<p>点击网站主导航"数据作者",进入数据作者页面后,点击左侧导航栏的"数据申请管理"。然后点击右侧页面顶部的"离线申请记录"(默认选中的是"在线下载记录")。该功能需要登录后使用(<a href="/author/inauthor/ac/offline">点击这里</a>可以进入离线申请记录)</p>
<p>3.离线数据申请审批</p>
<p>新建元数据时,可以通过多种方法来创建元数据。包括:创建一条空白元数据、根据已有模板创建元数据、根据已有元数据创建元数据、导入已有元数据等。</p>
<p>1.根据已有模板创建元数据:</p>
<p>在数据汇交页面左侧导航栏的"新建元数据",默认进入根据模板创建元数据页面。该功能需要登录后使用(<a href="/submit/newdata/">点击这里</a>可以进入在线申请记录)</p>
<p>2.根据已有数据创建元数据:</p>
<p>在数据汇交页面左侧导航栏的"新建元数据",然后点击右侧页面顶部的"根据已有数据创建元数据"(默认选中的是"根据已有模板创建元数据")。该功能需要登录后使用(<a href="/submit/newdata/ac/offline">点击这里</a>可以进入离线申请记录)</p>
<p>3.导入已有元数据</p>
<p>在数据汇交页面左侧导航栏的"新建元数据",然后点击右侧页面顶部的"导入已有元数据"(默认选中的是"根据已有模板创建元数据")。</p>
<p>4.从头创建元数据</p>
<p>进入"离线申请记录"页面后,在右侧页面可以看到离线申请列表,通过点击每条记录下面的"同意"按钮来确认同意用户的下载申请,点击"反对"来确认用户不能下载该数据。在数据送达前可以修改意见。当前数据如果已经有意见,则显示为淡蓝色背景(改类按钮表示被选中)</p>
</div>
</li>
<li>
<h1>元数据应该包括哪些要素?</h1>
<div class="content">
<p>数据中心采用ISO 19115元数据国际标准您在创建元数据的时候以下元数据要素应该明确</p>
1. 标题、副标题
标题应唯一,并且能简洁准确表达该数据。
2. 摘要
元数据中的摘要应为长摘要,能详细的介绍该数据。应尽量充实、完整的描述以下方面:
3. 关键词
元数据中的关键词有五大类,包括时间关键词、地点关键词、主题关键词、学科关键词、地层关键词。且应多填写。
</div>
</li>
<li>
<h1>如何上传数据?</h1>
<div class="content">
<p>创建了元数据后,就可以根据对应的元数据上传数据,而且,一条数据局可以上传多个对应的数据。(<a href="/submit/unsubmit">点击这里</a>查看未提交元数据列表)</p>
</div>
</li>
</ul>
</div>
</div>

View File

@ -1,5 +1,5 @@
<ul>
<li><a href="/submit/">介绍</a></li>
<li><a href="/submit/newdata">新建元数据</a></li>
<li><a href="/submit/">已提交的数据</a></li>
<li><a href="/submit/unsubmit">未提交数据</a></li>
</ul>

View File

@ -8,7 +8,7 @@ $this->headLink()->appendStylesheet('/css/author.css');
$this->headLink()->appendStylesheet('/css/colorbox.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/submit">数据汇交</a>');
$this->breadcrumb('数据新闻');
$this->breadcrumb('新建元数据');
$this->breadcrumb()->setSeparator(' > ');
?>
<!-- 左侧导航 -->
@ -23,7 +23,8 @@ $this->breadcrumb()->setSeparator(' > ');
<div id="wapper">
<div id="tabs-controller">
<ul>
<li class="box-shadow active"><a class="text-shadow" href="/submit/newdata">未提交数据列表</a></li>
<li class="box-shadow active"><a class="text-shadow" href="/submit/newdata">根据模板创建元数据</a></li>
<li class="box-shadow"><a class="text-shadow" href="/submit/newdata/ac/add">根据已有数据新建元数据</a></li>
<li class="box-shadow"><a class="text-shadow iframe" href="/service/geonetwork?url=metadata.xmlinsert.form">导入元数据</a></li>
<li class="box-shadow"><a class="text-shadow" href="/submit/newdata/ac/add">新建元数据</a></li>
</ul>

View File

@ -0,0 +1,99 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->submit);
$this->headTitle()->setSeparator(' - ');
$this->headScript()->appendFile('/js/jquery-1.7.min.js');
$this->headScript()->appendFile('/js/jquery.colorbox-min.js');
$this->headLink()->appendStylesheet('/css/author.css');
$this->headLink()->appendStylesheet('/css/colorbox.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/submit">数据汇交</a>');
$this->breadcrumb('未提交元数据');
$this->breadcrumb()->setSeparator(' > ');
?>
<!-- 左侧导航 -->
<div id='sidebar'>
<div id='leftnavi'>
<?= $this->partial('submit/navi.phtml'); ?>
</div>
</div>
<!-- //左侧导航 -->
<!-- 页面内容 -->
<div id="wapper">
<div id="datalist">
<?php
if (count($this->paginator)):
echo "<ul>";
$autoindex=0;
foreach ($this->paginator as $item):
$autoindex++;
?>
<li>
<p><span class="title"><?php echo $item['title'];?></span>
<a href="/service/geonetwork?url=metadata.show?id=<?php echo $item['id']; ?>">在geonetwork里查看</a>
| <a href="/service/geonetwork?url=metadata.edit?id=<?php echo $item['id']; ?>">在geonetwork里修改</a>
| <a href="/service/geonetwork?url=metadata.delete?id=<?php echo $item['id']; ?>">删除此条数据</a>
| <a href="/submit/upload/uuid/<?php echo $item['uuid'];?>" class="iframe">上传数据</a>
| <a href="/submit/files/uuid/<?php echo $item['uuid'];?>" class="iframe">管理数据</a>
| <a onclick="$('#commit_submit').attr('onclick','commit(\'<?php echo $item['id'];?>\');');" href="#commitform" class="more inline">提交评审发布</a>
</p>
</li>
<?php
endforeach;
echo "</ul>";
else :
echo "<p>您当前没有未提交的数据。</p>";
endif; ?>
</div>
<div class="pagenavi"><?= $this->paginator; ?></div>
</div>
<!-- //页面内容 -->
<script>
$(".iframe").colorbox({iframe:true, width:"80%",height:"80%"});
function action(ac,id){
$.ajax({
'type':"POST",
'url':'/submit/unsubmit/',
'data':'ac='+ ac +'&id='+id,
'success':function(data){
if (typeof(data)=='object')
{
if(typeof(data.error)!='undefined')
{$.colorbox({'innerWidth':'50%','html':data.error});}
if(typeof(data.deleted)!='undefined')
{$('#list_'+data.deleted).fadeOut("slow",function(){$(this).remove();});}
if(typeof(data.commited)!='undefined')
{$('#changelog').val('');$('#commit_submit').attr('onclick','');}
}
else{
$.colorbox({'innerWidth':'50%','html':'<img src="/images/alert_big_warning.png" /><h4>出现错误,请稍候再试</h4>'});
}
},
'timeout': 30000,
'error': function(){
$.colorbox({'innerWidth':'50%','html':'<img src="/images/alert_big_error.png" /><h4>处理中出现错误,请刷新页面后重试</h4>'});
}
});
}
$(".inline").colorbox({inline:true, width:"50%"});
function commit(id){
action('commit&changelog='+$('#changelog').val(),id);
}
</script>
<div class="colorbox" style="display:none;">
<div id="commitform">
<form>
<p>
<label>简要功能:</label><br />
<textarea class="full" style="resize:none;height:200px;" id="changelog"></textarea>
<br /><small>请输入此数据的简要功能和特色</small>
</p>
<input type="button" onclick="" id="commit_submit" class="btn btn-green big" value="提交"/>
</form>
</div>
<div class="error"><img src="/images/alert_big_error.png" /><span></span></div>
<div class="ok"><img src="/images/alert_big_ok.png" /><span></span></div>
<div class="warning"><img src="/images/alert_big_warning.png" /><span></span></div>
</div>

View File

@ -241,7 +241,7 @@ class files{
{
$save_path .= $uuid . "/";
$save_url .= $uuid . "/";
$dbsave = $uuid.'/';
$dbsave = $dir.'/'.$uuid.'/';
if (!file_exists($save_path)) {
mkdir($save_path);
}