From 9b20bab70eb0110ae86106906f263eaca1a8b721 Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Fri, 9 Nov 2012 09:58:33 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=BB=91=E6=B2=B3=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=B1=87=E4=BA=A4=E8=AE=A1=E5=88=92=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=99=A8=E3=80=81=E8=A7=86=E5=9B=BE=EF=BC=8C?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E4=B8=80=E9=83=A8=E5=88=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controllers/HeiheController.php | 370 ++++++++++++++++++ .../admin/views/scripts/heihe/index.phtml | 16 + .../admin/views/scripts/heihe/left.phtml | 4 + .../scripts/heihe/project-showexpert.phtml | 68 ++++ .../admin/views/scripts/heihe/project.phtml | 93 +++++ .../default/controllers/HeiheController.php | 95 ++++- .../default/views/scripts/heihe/navi.phtml | 1 + .../views/scripts/heihe/project-index.phtml | 59 +++ application/layouts/layout-iframe.phtml | 19 + application/models/news.php | 2 +- 10 files changed, 716 insertions(+), 11 deletions(-) create mode 100644 application/admin/controllers/HeiheController.php create mode 100644 application/admin/views/scripts/heihe/index.phtml create mode 100644 application/admin/views/scripts/heihe/left.phtml create mode 100644 application/admin/views/scripts/heihe/project-showexpert.phtml create mode 100644 application/admin/views/scripts/heihe/project.phtml create mode 100644 application/default/views/scripts/heihe/project-index.phtml create mode 100644 application/layouts/layout-iframe.phtml diff --git a/application/admin/controllers/HeiheController.php b/application/admin/controllers/HeiheController.php new file mode 100644 index 00000000..982d7323 --- /dev/null +++ b/application/admin/controllers/HeiheController.php @@ -0,0 +1,370 @@ +db=Zend_Registry::get('db'); + $this->view->config = Zend_Registry::get('config'); + } + + function postDispatch() + { + + } + + function indexAction() + { + + } + + /* + * projectsAction() 数据汇交计划 + * + * + * + * + */ + function projectAction() + { + $this->view->input_NameDefaultVal = "专家姓名"; + $this->view->input_EmailDefaultVal = "专家email"; + $projectTable = "heiheproject"; + + $ac = $this->_getParam('ac'); + + if(empty($ac) || $ac == "index") + { + $this->_helper->viewRenderer('project'); + + //Search Link + $this->view->searchLink = "/admin/heihe/project/ac/index/"; + + $q = $this->_getParam('q'); + + $wheresql = array(); + + if(!empty($q)) + { + $wheresql[] = " (title LIKE '%$q%' OR + code LIKE '%$q%' OR + name LIKE '%$q%' OR + email LIKE '%$q%')"; + $this->view->searchKeyword = $q; + } + + if(count($wheresql)>0) + { + $wheresql = join(" AND ",$wheresql); + }else{ + $wheresql = ""; + } + + if(!empty($wheresql)) + { + $wheresql = " WHERE ".$wheresql; + } + + $sql = "SELECT * FROM $projectTable $wheresql + ORDER BY id ASC"; + $sth = $this->db->query($sql); + $rows = $sth->fetchAll(); + + foreach ($rows as $k=>$v) + { + $rows[$k]['status'] = $this->replacestatus($v['status']); + } + + $this->view->Count = count($rows); + + $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; + + }//ac == index + + //邀请专家 + if($ac == "invite") + { + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + + $pid = $this->_getParam('id'); + $name = $this->_getParam('name'); + $email = $this->_getParam('email'); + + if(!is_numeric($pid)) + { + $this->jsonexit(array("error"=>"参数错误")); + return true; + } + + if(empty($name) || $name == $this->view->input_NameDefaultVal) + { + $this->jsonexit(array("error"=>"请输入专家姓名")); + return true; + } + + if(empty($email) || $email == $this->view->input_EmailDefaultVal) + { + $this->jsonexit(array("error"=>"请输入专家Email")); + return true; + } + + $sql = "SELECT * FROM $projectTable WHERE id=$pid"; + $sth = $this->db->query($sql); + $row = $sth->fetch(); + + $expert_name = $this->getArray($row['expert_name']); + $expert_email = $this->getArray($row['expert_email']); + + $name_list = array(); + $email_list = array(); + + if(is_array($expert_name) && count($expert_name)>0) + { + if(in_array($name,$expert_name)) + { + $this->jsonexit(array("error"=>"该专家的姓名已经存在")); + return true; + } + } + + if(is_array($expert_email) && count($expert_email)>0) + { + if(in_array($email,$expert_email)) + { + $this->jsonexit(array("error"=>"该专家的Email已经存在")); + return true; + } + } + + + $expert_name[] = $name; + $expert_email[] = $email; + + $name_list = $this->mkArray($expert_name); + $email_list = $this->mkArray($expert_email); + + $update = array("expert_name"=>$name_list,"expert_email"=>$email_list); + $where = "id=$pid"; + + if($this->db->update($projectTable,$update,$where)) + { + $this->sendMailToExpert($email); + $this->jsonexit(array("msg"=>"专家邀请成功!","invited"=>1)); + return true; + }else{ + $this->jsonexit(array("error"=>"邀请失败,请重试")); + return true; + } + + return true; + }// 邀请专家 + + if($ac == "showexpert") + { + $del = $this->_getParam('del'); + + if(isset($del)) + { + + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + }else{ + $this->_helper->layout->setLayout('layout-iframe'); + $this->_helper->viewRenderer('project-showexpert'); + } + + $pid = $this->_getParam('id'); + + if(empty($pid) || !is_numeric($pid)) + { + $this->view->error = "参数错误"; + return true; + } + + $this->view->pid = $pid; + + $sql = "SELECT * FROM $projectTable WHERE id=$pid"; + $sth = $this->db->query($sql); + $row = $sth->fetch(); + + if(empty($row['expert_name'])) + { + $this->view->error = "此项目还没有添加跟踪专家"; + return true; + } + + $names = $this->getArray($row['expert_name']); + $emails = $this->getArray($row['expert_email']); + + $experts = array(); + + foreach($names as $k=>$v) + { + $experts[$k] = array("name"=>$names[$k],"email"=>$emails[$k]); + } + + $this->view->experts = $experts; + + $del = $this->_getParam('del'); + + if(isset($del)) + { + + if(!is_numeric($del)) + { + $this->jsonexit(array("error"=>"参数错误")); + return true; + } + + unset($names[$del]); + unset($emails[$del]); + + $update = array( + "expert_name"=>$this->mkArray($names), + "expert_email"=>$this->mkArray($emails) + ); + $where = "id=$pid"; + + if($this->db->update($projectTable,$update,$where)) + { + $this->jsonexit(array("deleted"=>1)); + return true; + }else{ + $this->jsonexit(array("error"=>"邀请失败,请重试")); + return true; + } + + } + + + return true; + }//ac == showexpert 查看跟踪专家 + + if($ac == "unsubmit") + { + + }//ac == unsubmit 未提交 + + if($ac == "submit") + { + + }//ac == submit 已提交 + + }//projectsAction() + + function replacestatus($status) + { + if($status == 0) + { + return "计划未提交"; + } + if($status == 1) + { + return "计划未审核"; + } + if($status == 2) + { + return "跟踪专家审核"; + } + if($status == 3) + { + return "跟踪专家通过"; + } + if($status == 4) + { + return "数据委员会通过"; + } + } + + //从pgsql读取数组并拆分为php数组 + function getArray($str){ + if(strlen($str)>3) + { + return explode(",",substr($str,1,-1)); + }else{ + return NULL; + } + } + + //将php数组组装成pgsql中的数组 + function mkArray($array){ + if(!is_array($array)) + { + return "{".$array."}"; + } + if(count($array)==1) + { + $key = max(array_keys($array)); + return "{".$array[$key]."}"; + } + if(count($array)>1) + { + return "{".join(",",$array)."}"; + } + } + + //发送邀请专家的邮件 + function sendMailToExpert($name,$email) + { + $http_base = "http://".$_SERVER ['HTTP_HOST']; + $code = substr(md5($email),5,12); + $url = $http_base."/heihe/projects/invite/".$code; + + include_once("EmailText.php"); + $mailtp=new EmailText($this->db,"expert_invite",array( + 'name' => $name, + 'url' => $url, + )); + + //Email test code + + $mail_config = array( + 'ssl' => 'ssl', + 'port' => 465, + 'auth' => 'login', + 'username' => 'liujin834@gmail.com', + 'password' => 'hhagecysbgispqoz' + ); + $transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $mail_config); + Zend_Mail::setDefaultTransport($transport); + + $mail=new Zend_Mail(); + $body="aaa"; + $mail->setBodyText($body); + $mail->setFrom('liujin834@gmail.com','liujin834'); + $mail->addTo($email); + $mail->setSubject('数据跟踪专家邀请'); + $mail->send(); + + /* + include_once("EmailText.php"); + $mail=new WestdcMailer($this->view->config->smtp); + $mail->setFrom($this->view->config->service->email,'西部数据中心服务组'); + $mailtp=new EmailText($this->db,"author-new",array( + 'user' => $row['realname'], + 'uuid' => $row['uuid'], + 'title'=> $row['title'], + 'email'=> $row['email'], + )); + $mail->setBodyText($mailtp->getBody()); + $mail->setSubject($mailtp->getSubject()); + $mail->addTo($this->debug_email); + $mail->send(); + */ + + } + + public function jsonexit($data){ + $this->getResponse() + ->setHeader('Content-Type', 'application/json') + ->appendBody(json_encode($data,JSON_NUMERIC_CHECK)); + return true; + } + +} + diff --git a/application/admin/views/scripts/heihe/index.phtml b/application/admin/views/scripts/heihe/index.phtml new file mode 100644 index 00000000..2709833d --- /dev/null +++ b/application/admin/views/scripts/heihe/index.phtml @@ -0,0 +1,16 @@ +headTitle($this->config->title->site); + $this->headTitle('后台管理'); + $this->headTitle()->setSeparator(' - '); + $this->headLink()->appendStylesheet('/css/admin.css'); + $this->breadcrumb('首页'); + $this->breadcrumb('后台首页'); + $this->breadcrumb('黑河数据集'); + $this->breadcrumb()->setSeparator(' > '); +?> +
+partial('heihe/left.phtml'); ?> +
+
+ +
\ No newline at end of file diff --git a/application/admin/views/scripts/heihe/left.phtml b/application/admin/views/scripts/heihe/left.phtml new file mode 100644 index 00000000..79b6b829 --- /dev/null +++ b/application/admin/views/scripts/heihe/left.phtml @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/application/admin/views/scripts/heihe/project-showexpert.phtml b/application/admin/views/scripts/heihe/project-showexpert.phtml new file mode 100644 index 00000000..b78c2cef --- /dev/null +++ b/application/admin/views/scripts/heihe/project-showexpert.phtml @@ -0,0 +1,68 @@ +headTitle($this->config->title->site); + $this->headTitle('后台管理'); + $this->headTitle()->setSeparator(' - '); + $this->headLink()->appendStylesheet('/css/admin.css'); + $this->breadcrumb('首页'); + $this->breadcrumb('后台首页'); + $this->breadcrumb('黑河数据集'); + $this->breadcrumb('黑河数据集'); + $this->breadcrumb()->setSeparator(' > '); + $this->headScript()->appendFile('/js/jquery-1.7.min.js'); + $this->headScript()->appendFile('/js/jquery.colorbox-min.js'); + $this->headLink()->appendStylesheet('/css/colorbox.css'); + $this->headLink()->appendStylesheet('/css/author.css'); +?> +error)) +{ + echo $this->error; + echo ""; +}else{?> +
+ +
+ + + diff --git a/application/admin/views/scripts/heihe/project.phtml b/application/admin/views/scripts/heihe/project.phtml new file mode 100644 index 00000000..fd16cba9 --- /dev/null +++ b/application/admin/views/scripts/heihe/project.phtml @@ -0,0 +1,93 @@ +headTitle($this->config->title->site); + $this->headTitle('后台管理'); + $this->headTitle()->setSeparator(' - '); + $this->headLink()->appendStylesheet('/css/admin.css'); + $this->breadcrumb('首页'); + $this->breadcrumb('后台首页'); + $this->breadcrumb('黑河数据集'); + $this->breadcrumb('黑河数据集'); + $this->breadcrumb()->setSeparator(' > '); + $this->headScript()->appendFile('/js/jquery-1.7.min.js'); + $this->headScript()->appendFile('/js/jquery.colorbox-min.js'); + $this->headLink()->appendStylesheet('/css/colorbox.css'); + $this->headLink()->appendStylesheet('/css/author.css'); +?> +
+partial('heihe/left.phtml'); ?> +
+
+ searchLink)){ ?> +
+
+ + +
+
+ +
+ 共 Count; ?> 条记录 +
+
+ paginator)): + echo "
    "; + $autoindex=0; + foreach ($this->paginator as $item): + $autoindex++; + ?> +
  • +

    +

    编号: | 负责人: | 开始时间: | 状态:

    +

    + 邀请跟踪专家 |  + 查看跟踪专家 +

    + +
  • + "; + endif; ?> +
+ +
+ \ No newline at end of file diff --git a/application/default/controllers/HeiheController.php b/application/default/controllers/HeiheController.php index 424621d3..833e6565 100644 --- a/application/default/controllers/HeiheController.php +++ b/application/default/controllers/HeiheController.php @@ -441,7 +441,7 @@ class HeiheController extends DataController $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); - $data = ""; + $data = ""; $id = $this->_request->getParam('id'); try{ if(empty($id) || !is_numeric($id)) @@ -519,9 +519,9 @@ class HeiheController extends DataController $sql="delete from dataset where uuid=?"; $sth = $this->db->prepare($sql); $sth->execute(array($uuid)); - //自动添加数据分类为黑河 - $sql="insert into datasource (uuid,sourceid) values(?,1)"; - $sth=$this->db->prepare($sql); + //自动添加数据分类为黑河 + $sql="insert into datasource (uuid,sourceid) values(?,1)"; + $sth=$this->db->prepare($sql); try{$sth->execute(array($uuid));}catch(Exception $e) {} $sql = "INSERT INTO dataset (uuid,path) VALUES (?,?) RETURNING id"; @@ -536,7 +536,7 @@ class HeiheController extends DataController $this->jsonexit($data); return true; */ - } + } $temp = $sth->fetch(PDO::FETCH_ASSOC); @@ -608,11 +608,11 @@ class HeiheController extends DataController $data = array("commited"=>1,"error"=>'该版本已经成功提交,请等待数据中心进一步处理!'); $this->jsonexit($data); return true; - }catch(Exception $e) { - $sql="delete from mdstatus where uuid in (select uuid from geonetworkmetadata where id=?)"; - $this->db->query($sql,array($id)); - $sql="delete from mdauthor where userid=? and uuid in (select uuid from geonetworkmetadata where id=?)"; - $this->db->query($sql,array($u_id,$id)); + }catch(Exception $e) { + $sql="delete from mdstatus where uuid in (select uuid from geonetworkmetadata where id=?)"; + $this->db->query($sql,array($id)); + $sql="delete from mdauthor where userid=? and uuid in (select uuid from geonetworkmetadata where id=?)"; + $this->db->query($sql,array($u_id,$id)); $msg = "提交失败,请确认权限后重试"; if($this->debug>0) @@ -730,6 +730,81 @@ class HeiheController extends DataController }//function submitAction() + /* + * projectsAction() 数据汇交计划 + * + * + * + * + */ + function projectsAction() + { + + $ac = $this->_getParam('ac'); + + if(empty($ac) || $ac == "index") + { + $this->_helper->viewRenderer('project-index'); + + $sql = "SELECT * FROM heiheproject"; + $sth = $this->db->query($sql); + $rows = $sth->fetchAll(); + + foreach ($rows as $k=>$v) + { + $rows[$k]['status'] = $this->replacestatus($v['status']); + } + + $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; + + }//ac == index + + if($ac == "submitting") + { + + }//ac == submitting 正在提交 + + if($ac == "unsubmit") + { + + }//ac == unsubmit 未提交 + + if($ac == "submit") + { + + }//ac == submit 已提交 + + }//projectsAction() + + function replacestatus($status) + { + if($status == 0) + { + return "计划未提交"; + } + if($status == 1) + { + return "计划未审核"; + } + if($status == 2) + { + return "跟踪专家审核"; + } + if($status == 3) + { + return "跟踪专家通过"; + } + if($status == 4) + { + return "数据委员会通过"; + } + } + function genRandomString($len) { $chars = array( diff --git a/application/default/views/scripts/heihe/navi.phtml b/application/default/views/scripts/heihe/navi.phtml index 1e9525d8..cd727cda 100644 --- a/application/default/views/scripts/heihe/navi.phtml +++ b/application/default/views/scripts/heihe/navi.phtml @@ -34,6 +34,7 @@
  • 黑河计划数据汇交
  • 数据使用协议
  • -->
  • 数据汇交
  • +
  • 数据汇交计划