From a5bada218ca0370974a1a9985271e382f05e83fa Mon Sep 17 00:00:00 2001 From: wlx Date: Tue, 3 Apr 2012 03:15:07 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=B0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=8A=9F=E8=83=BD=EF=BC=8C=E8=BF=9B=E5=85=A5?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=AF=84=E5=AE=A1=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../default/controllers/AuthorController.php | 115 ++++++++++++++++++ .../views/scripts/author/newdata.phtml | 57 ++++++++- 2 files changed, 168 insertions(+), 4 deletions(-) diff --git a/application/default/controllers/AuthorController.php b/application/default/controllers/AuthorController.php index 7dd14084..7d77c45a 100644 --- a/application/default/controllers/AuthorController.php +++ b/application/default/controllers/AuthorController.php @@ -2108,6 +2108,121 @@ class AuthorController 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; + } + } } //文献管理 diff --git a/application/default/views/scripts/author/newdata.phtml b/application/default/views/scripts/author/newdata.phtml index e5710f3c..b577b8da 100644 --- a/application/default/views/scripts/author/newdata.phtml +++ b/application/default/views/scripts/author/newdata.phtml @@ -2,8 +2,10 @@ $this->headTitle($this->config->title->site); $this->headTitle($this->config->title->author); $this->headTitle()->setSeparator(' - '); -$this->headScript()->appendFile('/js/jquery-1.7.min.js'); -$this->headLink()->appendStylesheet('/css/author.css'); +$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('首页'); $this->breadcrumb('数据作者'); $this->breadcrumb('数据新闻'); @@ -37,7 +39,10 @@ $this->breadcrumb()->setSeparator(' > '); ?>
  • - 【在geonetwork里查看 | 在geonetwork里修改

    + 【在geonetwork里查看 + | 在geonetwork里修改 + | 提交评审发布 + 】

  • breadcrumb()->setSeparator(' > '); \ No newline at end of file +function action(ac,id){ + $.ajax({ + 'type':"POST", + 'url':'/author/newdata/', + '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':'

    出现错误,请稍候再试

    '}); + } + }, + 'timeout': 30000, + 'error': function(){ + $.colorbox({'innerWidth':'50%','html':'

    处理中出现错误,请刷新页面后重试

    '}); + } + }); +} +$(".inline").colorbox({inline:true, width:"50%"}); +function commit(id){ + action('commit&changelog='+$('#changelog').val(),id); +} + + \ No newline at end of file