842 lines
26 KiB
PHP
842 lines
26 KiB
PHP
<?php
|
||
class Admin_ReviewController extends Zend_Controller_Action
|
||
{
|
||
function preDispatch()
|
||
{
|
||
$this->db=Zend_Registry::get('db');
|
||
$this->view->config = Zend_Registry::get('config');
|
||
$this->messenger=$this->_helper->getHelper('FlashMessenger');
|
||
$this->view->messages = $this->messenger->getMessages();
|
||
}
|
||
function postDispatch()
|
||
{
|
||
$this->view->messages = $this->messenger->getMessages();
|
||
}
|
||
function indexAction()
|
||
{
|
||
$sql = "select m.id,md.title,u.username,u.realname,m.status from mdstatus m
|
||
left join metadata md on md.uuid=m.uuid
|
||
left join users u on u.id=m.userid
|
||
order by m.id desc limit 10 ";
|
||
$re = $this->db->query($sql);
|
||
$queue = $re->fetchAll();
|
||
|
||
foreach ($queue as $k=>$v)
|
||
{
|
||
$queue[$k]['status']=$this->rewritestatus($v['status']);
|
||
}
|
||
|
||
$this->view->queue = $queue;
|
||
|
||
|
||
$auth = Zend_Auth::getInstance();
|
||
if($auth->hasIdentity())
|
||
{
|
||
$user = $auth->getIdentity();
|
||
$userid = $user->id;
|
||
}
|
||
|
||
$sql = "select m.id,md.title,u.username,u.realname,m.status from mdstatus m
|
||
left join metadata md on md.uuid=m.uuid
|
||
left join users u on u.id=m.userid
|
||
where u.id='$userid'";
|
||
|
||
$re = $this->db->query($sql);
|
||
$rows = $re->fetchAll();
|
||
|
||
$this->view->my = $rows;
|
||
|
||
|
||
}//indexAction
|
||
|
||
function rewritestatus($status){
|
||
if($status==-1)
|
||
{return "取消评审";}
|
||
else if($status==0)
|
||
{return "初始状态";}
|
||
else if($status==1)
|
||
{return "接受元数据评审";}
|
||
else if($status==2)
|
||
{return "开始邀请专家";}
|
||
else if($status==3)
|
||
{return "专家接受邀请";}
|
||
else if($status==4)
|
||
{return "专家反馈";}
|
||
else if($status==5)
|
||
{return "已发布";}
|
||
else
|
||
{return "";}
|
||
}
|
||
|
||
/**
|
||
*changestatus
|
||
*
|
||
*@param int $id //要更改状态的mdstatus记录的ID
|
||
*@param int $status //状态
|
||
*
|
||
*/
|
||
function changestatus($id,$status){
|
||
$stvalues = array(
|
||
-1, //取消评审
|
||
0, //初始状态
|
||
1, //接受元数据评审,进入评审阶段
|
||
2, //开始邀请专家,送审阶段
|
||
3, //专家接受邀请,在审阶段
|
||
4, //专家反馈,在审
|
||
5 //评审结束,发布
|
||
);
|
||
if(empty($id) || !isset($status) || !in_array($status,$stvalues))
|
||
{
|
||
return false;
|
||
}
|
||
else
|
||
{
|
||
if($status==1)
|
||
{$sql = "update mdstatus set status='$status',ts_accepted='now()' where id in ($id)"; }
|
||
else if($status==5)
|
||
{$sql = "update mdstatus set status='$status',ts_finished='now()' where id in ($id)";}
|
||
else
|
||
{$sql = "update mdstatus set status='$status' where id in ($id)";}
|
||
try{
|
||
if($this->db->exec($sql)>0)
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
catch(Exception $e)
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
}//changestatus 更改状态
|
||
|
||
function acceptAction()
|
||
{
|
||
$search = $this->_request->getParam('search');
|
||
$cancel = $this->_request->getParam('cancel');
|
||
$update = $this->_request->getParam('update');
|
||
$invite = $this->_request->getParam('invite');
|
||
|
||
if($cancel>0)
|
||
{
|
||
if($this->changestatus($cancel,-1))
|
||
{
|
||
$this->messenger->addMessage('操作成功:已取消该数据的评审');
|
||
$this->_redirect("/admin/review/accept");
|
||
}
|
||
else{
|
||
$this->messenger->addMessage('操作失败');
|
||
$this->_redirect("/admin/review/accept");
|
||
}
|
||
}//取消元数据评审
|
||
if($search)
|
||
{
|
||
$keyword = $this->_request->getParam('keyword');
|
||
if(!empty($keyword))
|
||
{
|
||
$sql = "select m.*,u.username,u.realname from mdstatus m
|
||
left join metadata md on md.uuid=m.uuid
|
||
left join users u on u.id=m.userid
|
||
where m.status=1
|
||
and md.title like '%$keyword%'
|
||
";
|
||
$re = $this->db->query($sql);
|
||
$rows = $re->fetchAll();
|
||
|
||
$paginator = Zend_Paginator::factory($rows);
|
||
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
||
$paginator->setItemCountPerPage($this->view->config->page->max);
|
||
$paginator->setView($this->view);
|
||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
||
$this->view->paginator=$paginator;
|
||
}
|
||
}//搜索
|
||
else
|
||
{
|
||
$sql = "select m.*,md.title,u.username,u.realname from mdstatus m
|
||
left join metadata md on md.uuid=m.uuid
|
||
left join users u on u.id=m.userid
|
||
where m.status=1";
|
||
$re = $this->db->query($sql);
|
||
$rows = $re->fetchAll();
|
||
|
||
$paginator = Zend_Paginator::factory($rows);
|
||
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
||
$paginator->setItemCountPerPage($this->view->config->page->max);
|
||
$paginator->setView($this->view);
|
||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
||
$this->view->paginator=$paginator;
|
||
}//列表
|
||
|
||
}//acceptAction
|
||
|
||
function inreviewAction(){
|
||
|
||
$show = $this->_request->getParam('show');
|
||
$search = $this->_request->getParam('search');
|
||
$keyword = $this->_request->getParam('keyword');
|
||
|
||
if($show>0)
|
||
{
|
||
|
||
$sql = "select m.*,md.*,u.realname from mdstatus m
|
||
left join metadata md on md.uuid=m.uuid
|
||
left join users u on u.id=m.userid
|
||
where m.id=$show
|
||
";
|
||
|
||
$rs = $this->db->query($sql);
|
||
$rows = $rs->fetch();
|
||
|
||
$sql = "select exp.*,u.* from mdexpertreview exp
|
||
left join users u on u.id=exp.id
|
||
where exp.uuid='{$rows['uuid']}'";
|
||
$rs = $this->db->query($sql);
|
||
$exps = $rs->fetchAll();
|
||
|
||
$expname = array();
|
||
|
||
foreach ($exps as $k=>$v)
|
||
{
|
||
if($v['id']!='')
|
||
{$expname[] = '<a href="/admin/user/show/id/'.$v['id'].'">'.$v['realname'].'</a>';}
|
||
}
|
||
if(count($expname>0))
|
||
{$rows['exps'] = join(',',$expname);}
|
||
|
||
$rows['status'] = $this->rewritestatus($rows['status']);
|
||
|
||
$this->view->info = $rows;
|
||
|
||
|
||
$this->_helper->viewRenderer('inreviewshow');
|
||
|
||
}//查看详细
|
||
else
|
||
{
|
||
|
||
$searchjoin = "";
|
||
if(!empty($search) && !empty($keyword))
|
||
{
|
||
$searchjoin = " and md.title like '%$keyword%'";
|
||
$this->view->keyword = $keyword;
|
||
}
|
||
|
||
$sql = "select m.id,md.title,m.status,m.uuid from mdstatus m
|
||
left join metadata md on md.uuid=m.uuid
|
||
where m.status in (2,3,4) $searchjoin";
|
||
$rs = $this->db->query($sql);
|
||
$rows = $rs->fetchAll();
|
||
|
||
foreach ($rows as $k=>$v)
|
||
{
|
||
$rows[$k]['status']=$this->rewritestatus($v['status']);
|
||
}
|
||
|
||
$paginator = Zend_Paginator::factory($rows);
|
||
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
||
$paginator->setItemCountPerPage($this->view->config->page->max);
|
||
$paginator->setView($this->view);
|
||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
||
$this->view->paginator=$paginator;
|
||
}//列表
|
||
|
||
|
||
}//在审元数据
|
||
|
||
function inviteAction(){//邀请
|
||
|
||
$id = $this->_request->getParam('id');
|
||
if(empty($id))
|
||
{
|
||
$this->_redirect("/admin/review");
|
||
}
|
||
$search = $this->_request->getParam('search');
|
||
$keyword = $this->_request->getParam('keyword');
|
||
$submit = $this->_request->getParam('submit');
|
||
$exps = $this->_request->getParam('exps');
|
||
|
||
$stid = $this->_request->getParam('stid');
|
||
$uid = $this->_request->getParam('uid');
|
||
|
||
$this->view->id = $id;
|
||
|
||
if(!empty($submit))
|
||
{
|
||
if(is_array($exps))
|
||
{
|
||
$sql = "select m.uuid,m.title,s.status from metadata m
|
||
left join mdstatus s on s.uuid=m.uuid
|
||
where s.id='$id'";
|
||
|
||
$rs = $this -> db -> query($sql);
|
||
$md = $rs -> fetch();
|
||
|
||
$uuid = $md['uuid'];
|
||
|
||
foreach ($exps as $v)
|
||
{
|
||
$sql = "select m.id,u.realname,m.uuid,u.email from mdexpertreview m
|
||
left join users u on m.id=u.id
|
||
where m.uuid='$uuid' and m.id='$v'";
|
||
$rs = $this->db->query($sql);
|
||
$rows = $rs->fetch();
|
||
if($rows['id']!='')
|
||
{
|
||
$this->messenger->addMessage('已经邀请过专家:'.$rows['realname']);
|
||
}//已经有评审记录
|
||
else
|
||
{
|
||
|
||
$sql = "insert into mdexpertreview (id,uuid) values ('$v','$uuid')";
|
||
|
||
$expinfo="select realname,email from users where id='$v'";
|
||
$rs = $this->db->query($expinfo);
|
||
$expinfo = $rs->fetch();
|
||
|
||
try{
|
||
if($this->db->exec($sql)>0)
|
||
{
|
||
if($md['status']<2)
|
||
{
|
||
$update = "update mdstatus set status=2 where uuid='$uuid'";
|
||
@$this->db->exec($update);
|
||
}
|
||
//实例化EmailText
|
||
$mailtp=new EmailText($this->db,'invite-expert-review',array('user'=>$expinfo['realname'],'uuid'=>$uuid,'title'=>$md['title']));
|
||
$mail=new WestdcMailer($this->view->config->smtp);
|
||
$mail->setBodyText($mailtp->getBody());
|
||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||
$mail->addTo($expinfo['email']);
|
||
$mail->setSubject($mailtp->getSubject());
|
||
$filecontent=file_get_contents("http://" . $_SERVER['HTTP_HOST'].'/data/doc/uuid/'.$uuid);
|
||
$mail->createAttachment($filecontent,'application/octet-stream',Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, $md['title'].'.doc');
|
||
if($mail->send())
|
||
{
|
||
$this->messenger->addMessage('成功邀请专家:'.$expinfo['realname']);
|
||
}else
|
||
{
|
||
$this->messenger->addMessage('邀请专家'.$expinfo['realname'].'的邮件发送失败,请尝试手动发送邀请邮件');
|
||
}
|
||
}
|
||
}catch(Exception $e){
|
||
$this->messenger->addMessage('邀请失败:'.$e->getMessage());
|
||
}
|
||
}//不存在原来的记录
|
||
}//循环结束
|
||
$this->_redirect("/admin/review/invite/?id=$id");
|
||
}
|
||
else
|
||
{
|
||
$this->messenger->addMessage('请选择要邀请的专家');
|
||
$this->_redirect("/admin/review/invite/?id=$id");
|
||
}
|
||
}
|
||
$searchjoin = "";
|
||
if(!empty($search) && !empty($keyword))
|
||
{
|
||
$searchjoin = " where u.username like '%$keyword%'
|
||
or u.realname like '%$keyword%'
|
||
or u.unit like '%$keyword%'
|
||
or u.email like '%$keyword%'";
|
||
$this->view->keyword = $keyword;
|
||
}
|
||
|
||
$sql = "select me.id,u.username,u.realname,u.unit,u.phone,u.email from users u
|
||
right join mdexperts me on u.id=me.id
|
||
$searchjoin";
|
||
$re = $this->db->query($sql);
|
||
$rows = $re->fetchAll();
|
||
|
||
$paginator = Zend_Paginator::factory($rows);
|
||
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
||
$paginator->setItemCountPerPage($this->view->config->page->max);
|
||
$paginator->setView($this->view);
|
||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
||
$this->view->paginator=$paginator;
|
||
|
||
$sql = "select m.title from metadata m
|
||
left join mdstatus s on s.uuid=m.uuid
|
||
where s.id='$id'";
|
||
|
||
$re = $this->db->query($sql);
|
||
$title = $re->fetch();
|
||
$this->view->md=$title;
|
||
|
||
}//邀请专家
|
||
|
||
function changeadminAction(){
|
||
|
||
$id = $this->_request->getParam('id');
|
||
$uid = $this->_request->getParam('uid');
|
||
if(empty($id))
|
||
{
|
||
$this->_redirect("/admin/review");
|
||
}
|
||
|
||
$this->view->id = $id;
|
||
|
||
if(!empty($uid))
|
||
{
|
||
$sql = "update mdstatus set userid='$uid' where id='$id'";
|
||
if($this->db->exec($sql)>0)
|
||
{
|
||
$this->messenger->addMessage('更改管理员成功');
|
||
$this->_redirect("/admin/review/changeadmin/?id=$id");
|
||
}
|
||
}
|
||
|
||
|
||
$sql = "select u.* from users u
|
||
where usertype='administrator'";
|
||
$re = $this->db->query($sql);
|
||
$rows = $re->fetchAll();
|
||
|
||
$paginator = Zend_Paginator::factory($rows);
|
||
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
||
$paginator->setItemCountPerPage($this->view->config->page->max);
|
||
$paginator->setView($this->view);
|
||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
||
$this->view->paginator=$paginator;
|
||
|
||
}//改变管理员
|
||
|
||
|
||
function addonAction(){
|
||
|
||
$uuid=$this->_request->getParam('uuid');
|
||
|
||
$sql = "select * from mdstatus where uuid='$uuid'";
|
||
$re = $this->db->query($sql);
|
||
$row = $re->fetch();
|
||
|
||
if(empty($row['id']))
|
||
{
|
||
$auth = Zend_Auth::getInstance();
|
||
if($auth->hasIdentity())
|
||
{
|
||
$user = $auth->getIdentity();
|
||
$userid = $user->id;
|
||
$sql = "insert into mdstatus (uuid,userid,ts_scheduled,status) values ('$uuid','$userid','".date("Y-m-d H:i:s")."','0')";
|
||
try{
|
||
if($this->db->exec($sql)>0)
|
||
{
|
||
$this->messenger->addMessage('操作成功!该数据已放入评审');
|
||
$this->_redirect("/admin/review/draft");
|
||
}
|
||
}catch( Exception $e){
|
||
$this->messenger->addMessage('操作失败:'.$e->getMessage());
|
||
$this->_redirect("/admin/review/draft");
|
||
}
|
||
}
|
||
|
||
}
|
||
else
|
||
{
|
||
$this->messenger->addMessage('该数据已放入评审');
|
||
$this->_redirect("/admin/data/md");
|
||
}
|
||
|
||
}//将数据放入评审
|
||
|
||
function myreviewAction(){
|
||
|
||
$auth = Zend_Auth::getInstance();
|
||
if($auth->hasIdentity())
|
||
{
|
||
$user = $auth->getIdentity();
|
||
$userid = $user->id;
|
||
}
|
||
|
||
$search=$this->_request->getParam('search');
|
||
$keyword = $this->_request->getParam('keyword');
|
||
|
||
$searchjoin = "";
|
||
if(!empty($search) && !empty($keyword))
|
||
{
|
||
$searchjoin = " and md.title like '%$keyword%'";
|
||
$this->view->keyword = $keyword;
|
||
}
|
||
|
||
$sql = "select m.id,md.title,u.username,u.realname,m.status from mdstatus m
|
||
left join metadata md on md.uuid=m.uuid
|
||
left join users u on u.id=m.userid
|
||
where u.id='$userid' $searchjoin";
|
||
|
||
$re = $this->db->query($sql);
|
||
$rows = $re->fetchAll();
|
||
|
||
$paginator = Zend_Paginator::factory($rows);
|
||
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
||
$paginator->setItemCountPerPage($this->view->config->page->max);
|
||
$paginator->setView($this->view);
|
||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
||
$this->view->paginator=$paginator;
|
||
}//我管理的元数据
|
||
|
||
function draftAction(){
|
||
|
||
$search=$this->_request->getParam('search');
|
||
$keyword = $this->_request->getParam('keyword');
|
||
$update = $this->_request->getParam('update');
|
||
|
||
if($update>0 || is_array($update))
|
||
{
|
||
$ids = '';
|
||
if(is_array($update))$ids = join(',',$update);
|
||
else $ids=$update;
|
||
|
||
if($this->changestatus($ids,1))
|
||
{
|
||
$this->messenger->addMessage('操作成功!');
|
||
$this->_redirect("/admin/review/draft");
|
||
}
|
||
else{
|
||
$this->messenger->addMessage('操作失败');
|
||
$this->_redirect("/admin/review/accept");
|
||
}
|
||
|
||
}//开始评审
|
||
|
||
$searchjoin = "";
|
||
if(!empty($search) && !empty($keyword))
|
||
{
|
||
$searchjoin = " and md.title like '%$keyword%'";
|
||
$this->view->keyword = $keyword;
|
||
}
|
||
|
||
$sql = "select m.id,md.title,md.uuid,u.username,u.realname,m.status,m.ts_created from mdstatus m
|
||
left join metadata md on md.uuid=m.uuid
|
||
left join users u on u.id=m.userid
|
||
where status=0 $searchjoin";
|
||
|
||
$re = $this->db->query($sql);
|
||
$rows = $re->fetchAll();
|
||
|
||
$paginator = Zend_Paginator::factory($rows);
|
||
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
||
$paginator->setItemCountPerPage($this->view->config->page->max);
|
||
$paginator->setView($this->view);
|
||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
||
$this->view->paginator=$paginator;
|
||
|
||
}// draftAction 投稿元数据
|
||
|
||
function canceledAction(){
|
||
|
||
$search=$this->_request->getParam('search');
|
||
$keyword = $this->_request->getParam('keyword');
|
||
$update = $this->_request->getParam('update');
|
||
|
||
if($update>0 || is_array($update))
|
||
{
|
||
$ids = '';
|
||
if(is_array($update))$ids = join(',',$update);
|
||
else $ids=$update;
|
||
|
||
if($this->changestatus($ids,0))
|
||
{
|
||
$this->messenger->addMessage('操作成功!');
|
||
$this->_redirect("/admin/review/canceled");
|
||
}
|
||
else{
|
||
$this->messenger->addMessage('操作失败'.$ids);
|
||
$this->_redirect("/admin/review/canceled");
|
||
}
|
||
|
||
}//取消评审
|
||
|
||
$searchjoin = "";
|
||
if(!empty($search) && !empty($keyword))
|
||
{
|
||
$searchjoin = " and md.title like '%$keyword%'";
|
||
$this->view->keyword = $keyword;
|
||
}
|
||
|
||
$sql = "select m.id,md.title,md.uuid,u.username,u.realname,m.status from mdstatus m
|
||
left join metadata md on md.uuid=m.uuid
|
||
left join users u on u.id=m.userid
|
||
where status=-1 $searchjoin";
|
||
|
||
$re = $this->db->query($sql);
|
||
$rows = $re->fetchAll();
|
||
|
||
$paginator = Zend_Paginator::factory($rows);
|
||
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
||
$paginator->setItemCountPerPage($this->view->config->page->max);
|
||
$paginator->setView($this->view);
|
||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
||
$this->view->paginator=$paginator;
|
||
|
||
}//被取消评审的元数据
|
||
|
||
function reviewedAction(){
|
||
|
||
$search=$this->_request->getParam('search');
|
||
$keyword = $this->_request->getParam('keyword');
|
||
|
||
$searchjoin = "";
|
||
if(!empty($search) && !empty($keyword))
|
||
{
|
||
$searchjoin = " and md.title like '%$keyword%'";
|
||
$this->view->keyword = $keyword;
|
||
}
|
||
|
||
$sql = "select m.id,md.title,md.uuid,u.username,u.realname,m.status,m.ts_finished from mdstatus m
|
||
left join metadata md on md.uuid=m.uuid
|
||
left join users u on u.id=m.userid
|
||
where status=5 $searchjoin";
|
||
|
||
$re = $this->db->query($sql);
|
||
$rows = $re->fetchAll();
|
||
|
||
$paginator = Zend_Paginator::factory($rows);
|
||
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
||
$paginator->setItemCountPerPage($this->view->config->page->max);
|
||
$paginator->setView($this->view);
|
||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
||
$this->view->paginator=$paginator;
|
||
|
||
}//已结束评审
|
||
|
||
function expertsAction()
|
||
{
|
||
|
||
$search = $this->_request->getParam('search');
|
||
$keyword= $this->_request->getParam('keyword');
|
||
$submit = $this->_request->getParam('submit');
|
||
$edit = $this->_request->getParam('edit');
|
||
$del = $this->_request->getParam('del');
|
||
$add = $this->_request->getParam('add');
|
||
|
||
if($add)
|
||
{
|
||
if(!empty($submit))
|
||
{
|
||
|
||
foreach($_POST as $k=>$v)
|
||
{
|
||
$$k=$v;
|
||
}
|
||
|
||
$speciality = $_POST['speciality'];
|
||
|
||
$chars = array(
|
||
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
|
||
"l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
|
||
"w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G",
|
||
"H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",
|
||
"S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2",
|
||
"3", "4", "5", "6", "7", "8", "9"
|
||
);
|
||
$charsLen = count($chars) - 1;
|
||
|
||
shuffle($chars);
|
||
|
||
$output = "";
|
||
for ($i=0; $i<8; $i++)
|
||
{
|
||
$output .= $chars[mt_rand(0, $charsLen)];
|
||
}
|
||
|
||
$password=$output;
|
||
|
||
|
||
$testsql="select id from users where username='$username' or email='$email'";
|
||
$re=$this->db->query($testsql);
|
||
$test=$re->fetch();
|
||
|
||
if(!empty($test['id']))
|
||
{
|
||
$this->messenger->addMessage('用户名或邮箱重复');
|
||
$this->_redirect("/admin/review/experts");
|
||
|
||
}
|
||
|
||
else
|
||
{
|
||
|
||
$data = array(
|
||
'username' => $username,
|
||
'realname' => $realname,
|
||
'email' => $email,
|
||
'unit' => $unit,
|
||
'address' => $address,
|
||
'phone' => $phone,
|
||
'project' => $project,
|
||
'password' => md5($password)
|
||
);
|
||
|
||
if($this->db->insert('users',$data))
|
||
{
|
||
$mail=new WestdcMailer($this->view->config->smtp);
|
||
$mailtp=new EmailText($this->db,'expert-register',array('user'=>$username,'password'=>$password));
|
||
$mail->setBodyText($mailtp->getBody());
|
||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||
$mail->addTo($email);
|
||
$mail->setSubject($mailtp->getSubject());
|
||
$mail->send();
|
||
|
||
$sql="select id from users where username='{$data['username']}'";
|
||
$re=$this->db->query($sql);
|
||
$row = $re->fetch();
|
||
|
||
$sql="insert into mdexperts (id,speciality) values ('{$row['id']}','$speciality')";
|
||
if($this->db->exec($sql)>0)
|
||
{
|
||
$this->messenger->addMessage('成功添加评审专家');
|
||
$this->_redirect("/admin/review/experts");
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
}
|
||
else
|
||
{
|
||
$this->_helper->viewRenderer('expertsadd');
|
||
}
|
||
}
|
||
|
||
if($del>0)
|
||
{
|
||
$sql="delete from mdexperts where id='$del'";
|
||
if($this->db->exec($sql)>0)
|
||
{
|
||
$this->messenger->addMessage('删除成功!');
|
||
$this->_redirect('/admin/review/experts');
|
||
}
|
||
}
|
||
|
||
if($edit>0)
|
||
{
|
||
if(!empty($submit))
|
||
{
|
||
$speciality = $this->_request->getParam('speciality');
|
||
$sql = "update mdexperts set speciality='$speciality',ts_modified='".date("Y-m-d H:i:s",time())."' where id='$edit'";
|
||
if($this->db->exec($sql)>0)
|
||
{
|
||
$this->messenger->addMessage('编辑成功!');
|
||
$this->_redirect('/admin/review/experts');
|
||
}
|
||
}
|
||
else
|
||
{
|
||
$sql = "select m.*,m.id as mid,u.* from mdexperts m left join users u on u.id=m.id
|
||
where m.id='$edit'";
|
||
$re = $this->db->query($sql);
|
||
$row = $re->fetch();
|
||
$this->view->infos = $row;
|
||
$this->view->id=$edit;
|
||
|
||
$this->_helper->viewRenderer('expertsedit');
|
||
}
|
||
}//编辑
|
||
|
||
if($search)
|
||
{
|
||
|
||
$sql = "select m.*,m.id as mid,u.* from mdexperts m left join users u on u.id=m.id
|
||
where u.realname like '%$keyword%' or m.speciality like '%$keyword%' or u.unit like '%$keyword%'";
|
||
|
||
$re = $this->db->query($sql);
|
||
$rows = $re->fetchAll();
|
||
|
||
$paginator = Zend_Paginator::factory($rows);
|
||
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
||
$paginator->setItemCountPerPage($this->view->config->page->max);
|
||
$paginator->setView($this->view);
|
||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
||
$this->view->paginator=$paginator;
|
||
|
||
}//搜索
|
||
|
||
else
|
||
{
|
||
$sql="select m.*,m.id as mid,u.* from mdexperts m left join users u on u.id=m.id";
|
||
$re = $this->db->query($sql);
|
||
$rows = $re->fetchAll();
|
||
|
||
$paginator = Zend_Paginator::factory($rows);
|
||
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
||
$paginator->setItemCountPerPage($this->view->config->page->max);
|
||
$paginator->setView($this->view);
|
||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml');
|
||
$this->view->paginator=$paginator;
|
||
}//列表
|
||
|
||
|
||
}//expertsAction 专家库
|
||
|
||
/*
|
||
* 转换元数据为WORD DOC格式
|
||
*/
|
||
public function docAction()
|
||
{
|
||
$this->_helper->layout->disableLayout();
|
||
$this->_helper->viewRenderer->setNoRender();
|
||
$ua = $_SERVER["HTTP_USER_AGENT"];
|
||
$uuid=$this->_request->getParam('uuid');
|
||
if (!empty($uuid))
|
||
{
|
||
$sql="select x.data,m.title,m.description,g.id from xml x left join metadata m on m.id=x.id left join geonetworkmetadata g on g.uuid=m.uuid where m.uuid=".$this->db->quote($uuid);
|
||
$row=$this->db->fetchRow($sql);
|
||
}
|
||
|
||
$dom = new DOMDocument();
|
||
$dom->loadXML($row['data']);
|
||
//提前对表格进行预处理
|
||
$wiki=new WikiFormat();
|
||
$abs=$wiki->parseTable($this->view->escape($row["description"]));
|
||
//处理外部链接
|
||
$abs=preg_replace('/\[\s*(http:\/\/.+?)\s+(.*?)\]/m','<a href="$1">$2</a>',$abs);
|
||
$abs=str_replace(array("\r\n", "\n", "\r"),'</p><p>',$abs);
|
||
$abs=str_replace("'","'",$abs);//not needed?
|
||
$id = $row['id'];
|
||
$thumburl=sprintf('%05d',floor(($id+0.1)/100)*100).'-'.sprintf('%05d',ceil(($id+0.1)/100)*100-1)."/".$id;
|
||
$xslt = new XSLTProcessor();
|
||
$xslt->registerPHPFunctions();
|
||
$xslt->setParameter('', 'thumburl', $thumburl);
|
||
$xslt->setParameter('', 'abstract', $abs);
|
||
$XSL = new DOMDocument();
|
||
$XSL->load( '../data/doc.xsl', LIBXML_NOCDATA);
|
||
$xslt->importStylesheet($XSL);
|
||
$content='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
|
||
$content.='<title>'.$row['title'].'</title>';
|
||
$content.='<style>
|
||
body{MARGIN-RIGHT: auto;MARGIN-LEFT: auto;font-size:14px;line-height:22px;}
|
||
span{font-size:14px;}
|
||
div{clear: both;margin: 0 auto;width:100%;vertical-align:baseline;}
|
||
#uuid{text-align: right;}
|
||
h3{font-size: 18px;}
|
||
img {border:0 none;}
|
||
a, a:visited {color:Blue;text-decoration:none;}
|
||
a:hover{text-decoration:underline;}
|
||
ul{list-style: none;margin: 0;}
|
||
ul li{list-style:none;}
|
||
#etitle{font-size:16px;margin-left:10px;}
|
||
span{font-weight:bolder;}
|
||
#content{padding:5px 0 10px 0;border:1px solid #BF5008;}
|
||
#divFooter {background-color:#BF5008;color:White;font-size:12px;padding:5px 15px;}
|
||
#divFooter a:link, #divFooter a:visited, #divFooter a:active {color:White;font-family:Arial,Serif;text-decoration:none;}
|
||
</style>
|
||
</head>
|
||
<body>';
|
||
$content.=$xslt->transformToXML($dom);
|
||
$content.="</body></html>";
|
||
$this->getResponse()->setHeader('Content-Type', 'application/vnd.ms-doc')
|
||
->setHeader('Content-Disposition','attachment; filename="'.$row['title'].'.doc"')
|
||
->setHeader('Content-Length', strlen($content))
|
||
->setHeader('Content-Type','application/force-download')
|
||
->setHeader('Content-Type','application/download')
|
||
->setHeader('Content-Description','File Transfer')
|
||
->setHeader('Content-Transfer-Encoding','binary')
|
||
->setHeader('Expires',0)
|
||
->setHeader('Cache-Control','must-revalidate, post-check=0, pre-check=0')
|
||
->setHeader('Pragma','public')
|
||
->setBody($content);
|
||
}
|
||
}
|
||
|