2011-10-13 07:56:18 +00:00
< ? php
2012-01-13 09:12:02 +00:00
/**
* ReviewController
*
* @ description 元数据评审控制器
* @ version 2012 / 1 / 13 15 : 42
* @ category Controller
* @ package ReviewController
*/
2011-10-13 07:56:18 +00:00
class ReviewController extends Zend_Controller_Action
2011-10-28 10:00:13 +00:00
{
2011-10-27 14:30:52 +00:00
private $limit = 10 ;
2011-10-13 07:56:18 +00:00
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 ();
}
2012-01-13 09:12:02 +00:00
/*
* indexAction () 元数据评审首页
*/
2011-10-13 07:56:18 +00:00
function indexAction ()
{
//最新10个收稿
2012-05-16 01:10:41 +00:00
$sql = " select m.uuid,m.title,date(s.ts_created) as ts_created from mdstatus s right join metadata m on m.uuid=s.uuid where s.status=0 order by s.ts_created desc limit 10 " ;
2011-10-13 07:56:18 +00:00
$this -> view -> mdreceived = $this -> db -> fetchAll ( $sql );
//最新10个接收
2012-05-16 01:10:41 +00:00
$sql = " select m.uuid,m.title,s.ts_accepted from mdstatus s right join metadata m on m.uuid=s.uuid where s.status=1 order by s.ts_created desc limit 10 " ;
2011-10-13 07:56:18 +00:00
$this -> view -> mdaccepted = $this -> db -> fetchAll ( $sql );
//最新10个送审
2012-05-16 01:10:41 +00:00
$sql = " select m.uuid,m.title,s.ts_accepted from mdstatus s right join metadata m on m.uuid=s.uuid where s.status in (2,3,4) order by s.ts_created desc limit 10 " ;
2011-10-13 07:56:18 +00:00
$this -> view -> mdinreview = $this -> db -> fetchAll ( $sql );
//最新10个已审
2012-05-16 01:10:41 +00:00
$sql = " select m.uuid,m.title,s.ts_accepted from mdstatus s right join metadata m on m.uuid=s.uuid where s.status=5 order by s.ts_created desc limit 10 " ;
2011-10-13 07:56:18 +00:00
$this -> view -> mdreviewed = $this -> db -> fetchAll ( $sql );
//统计数字
$sql = " select (select count(*) from mdexperts) as experts,(select count(*) from mdstatus where status=0) as draft,(select count(*) from mdstatus where status=1) as accept,(select count(*) from mdstatus where status in (2,3,4)) as inreview,(select count(*) from mdstatus where status=5) as reviewed,(select count(*) from mdreview) as openreview,(select count(distinct(userid)) from mdreview) as openreviewuser " ;
$this -> view -> stat = $this -> db -> fetchRow ( $sql );
2012-01-13 09:12:02 +00:00
} // 元数据评审首页
2011-10-13 07:56:18 +00:00
2012-01-13 09:12:02 +00:00
/*
* myreviewAction () 我参数的元数据
*
* 通过用户ID来获得此列表, 未登录用户无权限浏览该页面
*/
2011-10-13 07:56:18 +00:00
function myreviewAction (){
2013-03-25 09:21:37 +00:00
$this -> view -> pageID = " review-myreview " ;
2011-10-28 02:32:39 +00:00
$auth = Zend_Auth :: getInstance ();
if ( $auth -> hasIdentity ())
{
$user = $auth -> getIdentity ();
$uid = $user -> id ;
} else {
$this -> _redirect ( '/account/login/?href=/review/myreview' );
2011-10-31 03:10:26 +00:00
}
$page =@ ( int ) $this -> _request -> getParam ( 'page' );
if ( empty ( $page )) $page = 1 ;
$offset = $this -> limit * ( $page - 1 );
$row = $this -> db -> fetchAll ( " select count(s.*) from mdstatus s left join normalmetadata m on s.uuid=m.uuid where m.uuid in (select uuid from mdexpertreview er where er.id= $uid union select uuid from mdreview r where r.userid= $uid ) " );
$sum = $row [ 0 ][ 'count' ];
$sql = " select m.uuid,m.title,m.id,m.description,s.status,s.ts_accepted,s.ts_finished,g.id as gid,t.filename from mdstatus s left join normalmetadata m on s.uuid=m.uuid left join geonetworkmetadata g on g.uuid=m.uuid left join thumbnail t on t.id=m.id where m.uuid in (select uuid from mdexpertreview er where er.id= $uid union select uuid from mdreview r where r.userid= $uid ) order by s.ts_created desc,m.title limit ? offset ? " ;
$this -> view -> metadata = $this -> db -> fetchAll ( $sql , array ( $this -> limit , $offset ));
$this -> view -> page = new Pagination ( $sum , $page , $this -> limit );
2011-10-28 02:32:39 +00:00
foreach ( $this -> view -> metadata as $k => $v )
{
$this -> view -> metadata [ $k ][ 'statustext' ] = $this -> rewritestatus ( $v [ 'status' ]);
}
2011-10-13 07:56:18 +00:00
} //我参审的
2012-01-13 09:12:02 +00:00
/*
* draftAction () 最新收稿的元数据
*
* [ @ param $page int ]
*
* mdstatus 中status 字段值为 0 的元数据为收稿元数据
*/
2011-10-13 07:56:18 +00:00
function draftAction (){
2013-03-26 03:56:42 +00:00
$this -> view -> pageID = " review-draft " ;
2011-10-31 03:10:26 +00:00
$page =@ ( int ) $this -> _request -> getParam ( 'page' );
if ( empty ( $page )) $page = 1 ;
$offset = $this -> limit * ( $page - 1 );
2012-12-03 03:37:37 +00:00
$row = $this -> db -> fetchAll ( " select count(s.*) from mdstatus s right join metadata m on s.uuid=m.uuid where s.status in (0) " );
2011-10-31 03:10:26 +00:00
$sum = $row [ 0 ][ 'count' ];
2012-12-02 02:36:49 +00:00
$sql = " select m.uuid,m.title,m.id,m.description,s.status,s.ts_created,g.id as gid,t.filename from mdstatus s right join metadata m on s.uuid=m.uuid left join geonetworkmetadata g on g.uuid=m.uuid left join thumbnail t on t.id=m.id where s.status in (0) order by s.ts_created desc,m.title limit ? offset ? " ;
2011-10-31 03:10:26 +00:00
$this -> view -> metadata = $this -> db -> fetchAll ( $sql , array ( $this -> limit , $offset ));
2011-10-28 02:32:39 +00:00
$this -> view -> page = new Pagination ( $sum , $page , $this -> limit );
2011-10-17 09:23:30 +00:00
} //最新收稿
2012-01-13 09:12:02 +00:00
/*
* acceptAction () 最新进入评审的元数据
*
* [ @ param $page int ]
*
* mdstatus 中 status 字段值为 1 的元数据为进入评审的元数据
*/
2011-10-17 09:23:30 +00:00
function acceptAction (){
2013-03-26 03:56:42 +00:00
$this -> view -> pageID = " review-accept " ;
2011-10-31 03:10:26 +00:00
$page =@ ( int ) $this -> _request -> getParam ( 'page' );
if ( empty ( $page )) $page = 1 ;
$offset = $this -> limit * ( $page - 1 );
2012-05-16 01:10:41 +00:00
$row = $this -> db -> fetchAll ( " select count(s.*) from mdstatus s right join normalmetadata m on s.uuid=m.uuid where s.status in (1) " );
2011-10-31 03:10:26 +00:00
$sum = $row [ 0 ][ 'count' ];
2012-05-16 01:10:41 +00:00
$sql = " select m.uuid,m.title,m.id,m.description,s.status,s.ts_accepted,g.id as gid,t.filename from mdstatus s right join normalmetadata m on s.uuid=m.uuid left join geonetworkmetadata g on g.uuid=m.uuid left join thumbnail t on t.id=m.id where s.status in (1) order by s.ts_created desc,m.title limit ? offset ? " ;
2011-10-31 03:10:26 +00:00
$this -> view -> metadata = $this -> db -> fetchAll ( $sql , array ( $this -> limit , $offset ));
2011-10-28 02:32:39 +00:00
$this -> view -> page = new Pagination ( $sum , $page , $this -> limit );
2012-01-13 09:12:02 +00:00
}
2011-10-13 09:30:53 +00:00
2012-01-13 09:12:02 +00:00
/*
* inreviewAction () 在审元数据
*
* [ @ param $page ( int )]
*
* mdstatus 中 status 字段值为 2 , 3 , 4 的元数据为正在进行评审的元数据
*/
2011-10-13 09:30:53 +00:00
function inreviewAction (){
2013-07-09 06:24:43 +00:00
include_once ( " helper/view.php " );
$ac = $this -> _getParam ( 'ac' );
if ( empty ( $ac ))
{
$this -> view -> pageID = " review-inreview " ;
$page =@ ( int ) $this -> _request -> getParam ( 'page' );
if ( empty ( $page )) $page = 1 ;
$offset = $this -> limit * ( $page - 1 );
$row = $this -> db -> fetchAll ( " select count(s.*) from mdstatus s right join normalmetadata m on s.uuid=m.uuid where s.status in (2,3,4) " );
$sum = $row [ 0 ][ 'count' ];
$sql = " select m.uuid,m.title,m.id,m.description,s.status,s.ts_accepted,g.id as gid,t.filename from mdstatus s right join normalmetadata m on s.uuid=m.uuid left join geonetworkmetadata g on g.uuid=m.uuid left join thumbnail t on t.id=m.id where s.status in (2,3,4) order by s.ts_created desc,m.title limit ? offset ? " ;
$this -> view -> metadata = $this -> db -> fetchAll ( $sql , array ( $this -> limit , $offset ));
$this -> view -> page = new Pagination ( $sum , $page , $this -> limit );
}
if ( $ac == " require " )
{
$this -> _helper -> viewRenderer ( 'inreview-require' );
$this -> view -> pageID = " review-inreview-require " ;
$uid = view :: User ( 'id' );
if ( empty ( $uid ))
{
view :: Post ( $this , " 请先登录 " , " /account/login/?href= " . urlencode ( " /review/inreview/ac/require " ));
}
$sql = " select m.uuid,m.title,m.id,m.description,s.status,s.ts_accepted,g.id as gid,t.filename,r.ts_created,r.id as rid,e.id as eid
from mdstatus s
right join normalmetadata m on s . uuid = m . uuid
left join geonetworkmetadata g on g . uuid = m . uuid
left join thumbnail t on t . id = m . id
left join mdreview r ON m . uuid = r . uuid
left join mdexpertreview e ON e . uuid = m . uuid
WHERE s . status in ( 2 , 3 , 4 ) AND r . id IS NULL
GROUP BY m . uuid , m . title , m . id , m . description , s . status , s . ts_accepted , g . id , t . filename , s . ts_created , r . ts_created , r . id , e . id
order by e . id DESC , s . ts_created desc , m . title " ;
$rs = $this -> db -> query ( $sql );
view :: addPaginator ( $rs -> fetchAll (), $this , NULL , $this -> limit );
}
if ( $ac == " reviewed " )
{
$this -> _helper -> viewRenderer ( 'inreview-reviewed' );
$this -> view -> pageID = " review-inreview-reviewed " ;
$uid = view :: User ( 'id' );
if ( empty ( $uid ))
{
view :: Post ( $this , " 请先登录 " , " /account/login/?href= " . urlencode ( " /review/inreview/ac/reviewed " ));
}
$sql = " select m.uuid,m.title,m.id,m.description,s.status,s.ts_accepted,g.id as gid,t.filename,r.ts_created
from mdstatus s
right join normalmetadata m on s . uuid = m . uuid
left join geonetworkmetadata g on g . uuid = m . uuid
left join thumbnail t on t . id = m . id
left join mdreview r ON m . uuid = r . uuid
WHERE s . status in ( 2 , 3 , 4 ) AND r . userid = $uid
GROUP BY m . uuid , m . title , m . id , m . description , s . status , s . ts_accepted , g . id , t . filename , s . ts_created , r . ts_created
order by s . ts_created desc , m . title " ;
$rs = $this -> db -> query ( $sql );
view :: addPaginator ( $rs -> fetchAll (), $this , NULL , $this -> limit );
}
2011-10-13 09:30:53 +00:00
} //在审阶段的元数据
2012-01-13 09:12:02 +00:00
/*
* reviewedAction () 已通过评审的元数据
*
* [ @ param $page int ]
*
* mdstatus 中 status 字段值为 5 的元数据为已经通过评审的元数据
*/
2011-10-13 09:42:04 +00:00
function reviewedAction (){
2013-03-26 03:56:42 +00:00
$this -> view -> pageID = " review-reviewed " ;
2011-10-31 03:10:26 +00:00
$page =@ ( int ) $this -> _request -> getParam ( 'page' );
if ( empty ( $page )) $page = 1 ;
$offset = $this -> limit * ( $page - 1 );
$row = $this -> db -> fetchAll ( " select count(s.*) from mdstatus s left join normalmetadata m on s.uuid=m.uuid where s.status in (5) " );
$sum = $row [ 0 ][ 'count' ];
$sql = " select m.uuid,m.title,m.id,m.description,s.status,s.ts_finished,g.id as gid,t.filename from mdstatus s left join normalmetadata m on s.uuid=m.uuid left join geonetworkmetadata g on g.uuid=m.uuid left join thumbnail t on t.id=m.id where s.status in (5) order by s.ts_created desc,m.title limit ? offset ? " ;
$this -> view -> metadata = $this -> db -> fetchAll ( $sql , array ( $this -> limit , $offset ));
2011-10-28 02:32:39 +00:00
$this -> view -> page = new Pagination ( $sum , $page , $this -> limit );
2011-10-13 09:42:04 +00:00
} //已完成评审的元数据
2012-01-13 09:12:02 +00:00
/*
* rewritestatus () 将评审状态转化为文字说明
*
* @ param $status int
*
* return string
*/
2011-10-27 14:49:00 +00:00
function rewritestatus ( $status ){
2011-10-13 09:30:53 +00:00
if ( $status ==- 1 )
{ return " 取消评审 " ;}
else if ( $status == 0 )
2011-10-27 14:49:00 +00:00
{ return " 投稿元数据 " ;}
2011-10-13 09:30:53 +00:00
else if ( $status == 1 )
2011-10-27 14:49:00 +00:00
{ return " 接收元数据 " ;}
2011-10-13 09:30:53 +00:00
else if ( $status == 2 )
{ return " 专家评审中 " ;}
else if ( $status == 3 )
{ return " 专家评审中 " ;}
else if ( $status == 4 )
{ return " 专家反馈 " ;}
else if ( $status == 5 )
{ return " 已发布 " ;}
else
{ return " " ;}
} //function rewriterstatus
2011-10-14 10:29:26 +00:00
2012-01-13 09:12:02 +00:00
/*
* replace () 重写表单中提交的html数据
*
* @ param $string string
*
* return string
*/
2011-10-14 10:29:26 +00:00
function replace ( $string ){
$patterns = array ( " / \" /i " , " / \ '/i " );
$replacements = array ( " “ " , " ‘ " );
ksort ( $patterns );
ksort ( $replacements );
return preg_replace ( $patterns , $replacements , $string );
}
2012-01-13 09:12:02 +00:00
/*
* reviewAction () 元数据评审页面
*
* @ param $uuid uuid
*
* return view
*/
2011-10-14 10:29:26 +00:00
function reviewAction () {
$uuid = $this -> _request -> getParam ( 'uuid' );
2011-10-18 08:15:32 +00:00
$sql = $this -> db -> quoteInto ( " select m.id,m.uuid,m.title,m.description,m.title_en,r.status from metadata m
left join mdstatus r on r . uuid = m . uuid
where m . uuid = ? " , $uuid );
2011-10-28 10:00:13 +00:00
$md = $this -> db -> fetchRow ( $sql );
$this -> view -> metadata = $md ;
2011-10-17 08:10:25 +00:00
$auth = Zend_Auth :: getInstance ();
if ( $auth -> hasIdentity ())
{
$user = $auth -> getIdentity ();
$userid = $user -> id ;
2011-10-31 03:10:26 +00:00
$sql = " select * from mdreview where userid=' $userid ' and uuid=' $uuid ' " ;
2011-10-17 08:10:25 +00:00
$rs = $this -> db -> query ( $sql );
$row = $rs -> fetch ();
2011-10-31 03:10:26 +00:00
$this -> view -> review = $row ;
2011-10-14 10:29:26 +00:00
}
} //reviewAction()
2012-01-13 09:12:02 +00:00
/*
* allreviewAction () 列出所有评审意见
*
* @ param $uuid uuid
* @ param $page int default 0
*
* return string
*
* 使用ajax输出所有评审意见, UUID为数据评审页面的uuid参数。包含列表的html标签, 包含分页代码
* 分页模板: review / pagination_ajax . phtml
*/
2011-10-17 08:10:25 +00:00
function allreviewAction (){
2011-10-18 01:41:20 +00:00
$this -> _helper -> layout -> disableLayout ();
$this -> _helper -> viewRenderer -> setNoRender ();
2011-10-17 08:10:25 +00:00
$uuid = $this -> _request -> getParam ( 'uuid' );
2011-12-07 08:57:40 +00:00
$sql = " select r.id,r.is_expert,r.uuid,r.userid,r.ts_created,u.username,r.mdcomment,r.conclusion,ratt.reviewid from mdreview r
2011-10-17 08:10:25 +00:00
left join users u on u . id = r . userid
2011-11-08 06:40:18 +00:00
left join mdreviewattach ratt on r . id = ratt . reviewid
2011-11-08 04:02:04 +00:00
where r . uuid = '$uuid' and r . status >- 1
2011-12-07 08:57:40 +00:00
group by r . id , r . is_expert , r . uuid , r . userid , r . ts_created , u . username , r . mdcomment , r . conclusion , ratt . reviewid
2011-11-08 07:47:10 +00:00
order by r . id desc
2011-11-08 04:02:04 +00:00
" ;
2011-10-17 08:10:25 +00:00
$rs = $this -> db -> query ( $sql );
$rows = $rs -> fetchAll ();
$paginator = Zend_Paginator :: factory ( $rows );
$paginator -> setCurrentPageNumber ( $this -> _getParam ( 'page' ));
2011-10-18 01:41:20 +00:00
$paginator -> setItemCountPerPage ( 5 );
$paginator -> setView ( $this -> view );
2011-10-17 10:20:19 +00:00
Zend_View_Helper_PaginationControl :: setDefaultViewPartial ( 'review/pagination_ajax.phtml' );
2011-10-17 08:10:25 +00:00
$list = " " ;
2011-10-18 01:41:20 +00:00
foreach ( $paginator as $k => $v )
2011-10-17 08:10:25 +00:00
{
$list .= '
< li >
2011-12-01 02:24:37 +00:00
< div class = " reviewitem " >
< div class = " itemtitle " > 评审人: ' ;
2011-12-07 08:57:40 +00:00
if ( ! $v [ 'is_expert' ])
2011-12-01 02:24:37 +00:00
{
$list .= $v [ 'username' ];
} else
{
$list .= '专家' ;
}
$list .= '</div><div class="itemtime">' ;
2011-11-08 04:02:04 +00:00
if ( $v [ 'reviewid' ] != " " )
{
$list .= '[<a href="javascript:;" onclick="checkfiles(\'' . $v [ 'id' ] . '\')">查看评审附件</a>] ' ;
}
$list .= '
评审时间: '.date("Y-m-d H:i",strtotime($v[' ts_created '])).' </ div >
2011-10-17 09:05:46 +00:00
< div class = " itemcontent " >< p > '.str_replace(array("\r\n", "\n", "\r"),' </ p >< p > ',$v[' mdcomment ']).' </ p ></ div >
2011-11-08 04:02:04 +00:00
< div id = " filelist_'. $v['id'] .' " class = " filelist " ></ div >
2011-10-17 08:10:25 +00:00
</ div >
</ li >
' ;
}
2011-10-28 10:00:13 +00:00
if ( empty ( $list ))
{
$list = " <p style='text-align:center'>暂无评审数据</p> " ;
}
2011-10-17 08:10:25 +00:00
$stringbuffer = " <ul class='reviewlist'> $list </ul> " ;
2011-10-18 01:41:20 +00:00
2011-10-17 08:10:25 +00:00
echo $stringbuffer . '<div class="paginator">' . $paginator . '</div>' ;
2011-10-28 10:00:13 +00:00
} //allreviewAction() 所有评论 ajax
2012-01-13 09:12:02 +00:00
/*
* saveAction () 保存 / 提交评审意见
*
* @ param $do string //空值或其它时为存草稿, submit为提交到后台
* @ param $conclusion int //总体意见
* @ param $mdcomment string //给元数据意见
* @ param $datacomment string //给数据中心意见
* @ param $editorcomment string //给元数据作者意见
* @ param $att array [] //附件
* @ param $uuid uuid
*
* return string
*
* ajax保存、提交元数据评审意见, 返回提示html提示信息
* 当用户未删除附件直接离开页面会产生冗余, 因为附件没有即时删除( 是否在离开事件中添加ajax删除未提交的附件? )
* 评审成功后发送邮件到系统邮箱,并为后台推送管理员消息
*/
2011-10-28 10:00:13 +00:00
function saveAction (){
$this -> _helper -> layout -> disableLayout ();
$this -> _helper -> viewRenderer -> setNoRender ();
2011-11-04 08:01:27 +00:00
$do = $this -> _request -> getParam ( 'do' );
2011-10-31 03:10:26 +00:00
$conclusion = $this -> _request -> getParam ( 'conclusion' );
$mdcomment = $this -> replace ( trim ( $this -> _request -> getParam ( 'mdcomment' )));
$datacomment = $this -> replace ( trim ( $this -> _request -> getParam ( 'datacomment' )));
$editorcomment = $this -> replace ( trim ( $this -> _request -> getParam ( 'editorcomment' )));
$uuid = $this -> _request -> getParam ( 'uuid' );
$sql = $this -> db -> quoteInto ( " select m.id,m.uuid,m.title,m.description,m.title_en,r.status from metadata m
left join mdstatus r on r . uuid = m . uuid
where m . uuid = ? " , $uuid );
$md = $this -> db -> fetchRow ( $sql );
if ( $md [ 'status' ] > 4 )
{
echo '<div class="box box-info">该数据已经通过评审,不能再发表评审意见,如需提交问题,请联系数据管理员</div>' ;
exit ();
}
if ( $md [ 'status' ] < 1 )
{
echo '<div class="box box-info">已被数据中心接收的数据才可以进行评审</div>' ;
exit ();
}
$auth = Zend_Auth :: getInstance ();
if ( $auth -> hasIdentity ())
{
$user = $auth -> getIdentity ();
$userid = $user -> id ;
$sql = " select id,userid,status from mdreview where userid=' $userid ' and uuid=' $uuid ' " ;
$rs = $this -> db -> query ( $sql );
$row = $rs -> fetch ();
if ( $row [ 'id' ] != '' && $row [ 'status' ] >- 1 )
{
echo '<div class="box box-info">您已经对该元数据发表过评审了</div>' ;
exit ();
}
} else {
echo '<div class="box box-info">读取用户信息失败,请刷新页面后重试 :(</div>' ;
exit ();
}
if ( empty ( $conclusion ))
{
echo '<div class="box box-info">请选择评审意见</div>' ;
exit ();
}
if ( ! is_numeric ( $conclusion ) || ! in_array ( $conclusion , array ( - 1 , 1 , 2 , 3 )))
{
echo '<div class="box box-info">参数有误,请刷新页面 :(</div>' ;
exit ();
}
if ( empty ( $mdcomment ) )
{
2011-11-04 08:01:27 +00:00
echo '<div class="box box-info">请填写元数据意见 :(</div>' ;
2011-10-31 03:10:26 +00:00
exit ();
}
try {
if ( $row [ 'status' ] < 0 )
{
$sql = " delete from mdreview where id=' { $row [ 'id' ] } ' " ;
if ( $this -> db -> exec ( $sql ) < 1 )
{
echo '<div class="box box-error">处理出错,请重试</div>' ;
exit ();
}
}
$data = array (
'userid' => $userid ,
'uuid' => $uuid ,
'mdcomment' => $mdcomment ,
'ts_created' => 'now()' ,
'datacomment' => $datacomment ,
'editorcomment' => $editorcomment ,
'conclusion' => $conclusion ,
'status' => - 1
);
2011-11-04 08:01:27 +00:00
if ( $do == 'submit' )
{
$data [ 'status' ] = 0 ;
}
2011-10-31 03:10:26 +00:00
$sql = " select id from mdexpertreview where id=' $userid ' and uuid=' $uuid ' " ;
$rs = $this -> db -> query ( $sql );
$row = $rs -> fetch ();
if ( $row [ 'id' ] != '' )
{
$data [ 'is_expert' ] = 'true' ;
}
$keys = array ();
$values = array ();
foreach ( $data as $k => $v )
{
$keys [] = $k ;
$values [] = $v ;
}
$keys = join ( " , " , $keys );
$values = " ' " . join ( " ',' " , $values ) . " ' " ;
$sql = " insert into mdreview ( $keys ) values ( $values ) RETURNING id " ;
$sth = $this -> db -> prepare ( $sql );
2011-11-01 02:01:22 +00:00
if ( $sth -> execute ())
{
2011-11-16 10:02:42 +00:00
$review = $sth -> fetch ( PDO :: FETCH_ASSOC );
$reviewid = $review [ 'id' ];
2011-11-08 07:09:23 +00:00
if ( isset ( $_POST [ 'atts' ]))
2011-11-16 10:02:42 +00:00
{
2011-12-07 08:57:40 +00:00
foreach ( $_POST [ 'atts' ] as $v )
{
$sql = " insert into mdreviewattach (attachid,reviewid) values (' $v ',' $reviewid ') " ;
$this -> db -> exec ( $sql );
2011-11-04 08:01:27 +00:00
}
2011-12-07 08:57:40 +00:00
echo '<div class="box box-success">保存成功!' ;
2011-12-29 09:39:07 +00:00
echo " </div> " ;
2011-12-07 08:57:40 +00:00
}
if ( $data [ 'status' ] >= 0 )
{
echo '<script>$("#postcomment").remove();</script>' ;
$title = " 收到新元数据评审意见 " ;
$msg = " 用户 " . $user -> username . " 对元数据《 " . $md [ 'title' ] . " 》发布了评审意见,<a href= \" /admin/review/comments/ac/view/id/ " . $reviewid . " \" >点击查看</a> " ;
include_once ( " message.php " );
message :: post ( $this -> db , 0 , - 1 , $title , $msg );
$mail = new WestdcMailer ( $this -> view -> config -> smtp );
2018-05-12 07:42:11 +00:00
$mail -> setFrom ( $this -> view -> config -> service -> email , '时空三极环境大数据平台服务组' );
2011-12-07 08:57:40 +00:00
if ( @ $data [ 'is_expert' ] == 'true' )
2011-12-29 09:39:07 +00:00
{
2011-12-07 08:57:40 +00:00
$mailtp = new EmailText ( $this -> db , " review-expert-comment " , array (
'user' => $user -> username ,
'uuid' => $uuid ,
'title' => $md [ 'title' ],
'content' => $mdcomment
2011-12-29 09:39:07 +00:00
));
$mail -> setBodyText ( $mailtp -> getBody ());
2011-12-07 08:57:40 +00:00
$mail -> setSubject ( $mailtp -> getSubject ());
$mail -> addTo ( $this -> view -> config -> service -> email ); //管理员邮箱
} else {
$mailtp = new EmailText ( $this -> db , " review-post-comment " , array (
'user' => $user -> username ,
'uuid' => $uuid ,
'title' => $md [ 'title' ],
'content' => $mdcomment
2011-12-29 09:39:07 +00:00
));
$mail -> setBodyText ( $mailtp -> getBody ());
$mail -> setSubject ( $mailtp -> getSubject ());
$sql = " select distinct(res.email) from responsible res left join role r on res.id=r.resid where r.role in ('author','resourceProvider') and r.uuid=? " ;
$rows = $this -> db -> fetchAll ( $this -> db -> quoteInto ( $sql , $uuid ));
2011-12-07 08:57:40 +00:00
foreach ( $rows as $row )
$mail -> addTo ( $row [ 'email' ]); //元数据作者
$mail -> addCc ( $this -> view -> config -> service -> email ); //管理员
}
$mail -> send ();
2011-11-04 08:01:27 +00:00
}
2011-11-01 02:01:22 +00:00
} else {
2011-11-15 08:54:42 +00:00
echo '<div class="box box-error">保存出错,请稍后再试!</div>' ;
2011-11-01 02:01:22 +00:00
exit ();
}
2011-10-31 03:10:26 +00:00
} catch ( Exception $e ){
echo '<div class="box box-error">保存失败,请重试!</div>' ;
exit ();
}
2011-10-28 10:00:13 +00:00
} // saveAction 存草稿 ajax
2011-10-27 14:30:52 +00:00
2012-01-13 09:12:02 +00:00
/*
* searchAction () 搜索
*
* @ param $key string
*
* 搜索包含输入关键词的评审元数据
*/
function searchAction ()
{
2011-10-28 10:00:13 +00:00
$key = $this -> _request -> getParam ( 'q' );
2011-12-29 09:39:07 +00:00
if ( preg_match ( " / \" |'|<|>/ " , $key ))
{
$data = array (
'<' => '<' ,
'>' => '>' ,
" \ ' " => '’ ' ,
" \" " => '”' ,
);
$patterns = array ();
$replacements = array ();
foreach ( $data as $k => $v )
{
$patterns [] = '/' . $k . '/i' ;
$replacements [] = $v ;
}
ksort ( $patterns );
ksort ( $replacements );
$key = preg_replace ( $patterns , $replacements , $key );
}
2011-10-28 10:00:13 +00:00
if ( ! empty ( $key )) {
2013-04-10 04:08:10 +00:00
$search = new SimpleSearch ( $key );
2011-10-28 10:00:13 +00:00
$where = $search -> sql_expr ( array ( " m.title " , " m.description " ));
$page =@ ( int ) $this -> _request -> getParam ( 'page' );
if ( empty ( $page )) $page = 1 ;
$offset = $this -> limit * ( $page - 1 );
$row = $this -> db -> fetchAll ( " select count(s.*) from mdstatus s left join normalmetadata m on s.uuid=m.uuid where s.status>0 and " . $where );
$sum = $row [ 0 ][ 'count' ];
$sql = " select m.uuid,m.title,m.id,m.description,s.status,g.id as gid,t.filename from mdstatus s left join normalmetadata m on s.uuid=m.uuid left join geonetworkmetadata g on g.uuid=m.uuid left join thumbnail t on t.id=m.id where s.status>0 and " . $where . " order by s.ts_created desc,m.title limit ? offset ? " ;
$this -> view -> metadata = $this -> db -> fetchAll ( $sql , array ( $this -> limit , $offset ));
$this -> view -> page = new Pagination ( $sum , $page , $this -> limit );
$this -> view -> key = $key ;
2011-10-27 14:49:00 +00:00
foreach ( $this -> view -> metadata as $k => $v )
{
$this -> view -> metadata [ $k ][ 'statustext' ] = $this -> rewritestatus ( $v [ 'status' ]);
2013-05-03 06:41:06 +00:00
}
2011-10-28 10:00:13 +00:00
}
2012-01-13 09:12:02 +00:00
}
function helpAction ()
2013-05-03 06:41:06 +00:00
{
$archives = new Archive ( $this -> db );
$this -> view -> item = $archives -> getOneArchive ( '元数据评审说明' , 'help' );
2013-05-03 01:30:03 +00:00
$this -> view -> pageID = " review-help " ;
2012-01-13 09:12:02 +00:00
}
2011-11-08 04:02:04 +00:00
2012-01-13 09:12:02 +00:00
/*
* attlistAction () 元数据评审附件列表
*
* @ param $rid status //元数据评审意见的ID
*
* return string
*
* ajax获得评审意见的附件列表, 输出html
*/
2011-11-08 04:02:04 +00:00
function attlistAction ()
{
$this -> _helper -> layout -> disableLayout ();
$this -> _helper -> viewRenderer -> setNoRender ();
$rid = $this -> _request -> getParam ( 'id' );
$list = array ();
$list [] = '
< li style = " border:none " >
附件列表:
< span >< a href = " javascript:void(0); " onclick = " $ ( \ '#filelist_'. $rid .' ul \ ').remove(); " > [ 关闭 ] </ a ></ span >
</ li >
' ;
2011-11-08 07:18:46 +00:00
$sql = " select att.realname,att.id,att.filesize from attachments att
2011-11-08 04:02:04 +00:00
left join mdreviewattach ratt on ratt . attachid = att . id
where ratt . reviewid = $rid " ;
$rs = $this -> db -> query ( $sql );
$rows = $rs -> fetchAll ();
foreach ( $rows as $k => $v )
{
2011-11-08 07:18:46 +00:00
if ( $v [ 'filesize' ] > 1024 * 1024 )
{
$v [ 'filesize' ] = round ( $v [ 'filesize' ] / 1024 / 1024 , 2 ) . " MB " ;
}
else
{
$v [ 'filesize' ] = round ( $v [ 'filesize' ] / 1024 , 2 ) . " KB " ;
}
2011-11-08 04:02:04 +00:00
$list [] = '
2011-11-08 07:18:46 +00:00
< li > '.$v[' realname '].' & nbsp ;( '.$v[' filesize '].' )
2011-11-08 08:04:11 +00:00
< span >< a href = " /review/downatt/id/'. $v['id'] .' " target = " _blank " > 下载 </ a ></ span >
2011-11-08 04:02:04 +00:00
</ li >
' ;
}
if ( count ( $rows ) > 0 )
{
echo " <ul> " . join ( '' , $list ) . " </ul> " ;
} else {
echo " 无附件 " ;
}
exit ();
} // ajax 评审附件列表
2011-11-08 07:09:23 +00:00
2012-01-13 09:12:02 +00:00
/*
* downattAction () 附加下载
*
* @ param $id int //附件ID
*
* return file
*
* 判断附件类型后输出相应下载
* 如果输出html错误提示, 需要输出完整的html页面
*/
2011-11-08 07:09:23 +00:00
function downattAction (){
$this -> _helper -> layout -> disableLayout ();
$this -> _helper -> viewRenderer -> setNoRender ();
$id = $this -> _request -> getParam ( 'id' );
2011-11-08 08:04:11 +00:00
$auth = Zend_Auth :: getInstance ();
if ( $auth -> hasIdentity ())
{
try {
$sql = " select * from attachments where id=' $id ' " ;
2011-11-08 07:09:23 +00:00
2011-11-08 08:04:11 +00:00
$re = $this -> db -> query ( $sql );
$row = $re -> fetch ();
$fullPath = $this -> view -> config -> upload . $row [ 'filename' ];
2011-11-14 02:54:10 +00:00
if ( ! file_exists ( $fullPath ))
{
echo ' <! DOCTYPE html PUBLIC " -//W3C//DTD XHTML 1.0 Transitional//EN " " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
< html xmlns = " http://www.w3.org/1999/xhtml " >
< head >< meta http - equiv = " Content-Type " content = " text/html; charset=utf-8 " />
< title > 错误提示! </ title ></ head >< body > 文件读取出错,请稍后重试 </ body ></ html > ' ;
exit ();
}
2011-11-08 08:04:11 +00:00
$fsize = filesize ( $fullPath );
$path_parts = pathinfo ( $fullPath );
$ext = strtolower ( $path_parts [ " extension " ]);
switch ( $ext ) {
case " pdf " : $ctype = " application/pdf " ; break ;
case " exe " : $ctype = " application/octet-stream " ; break ;
case " zip " : $ctype = " application/zip " ; break ;
case " doc " : $ctype = " application/msword " ; break ;
case " xls " : $ctype = " application/vnd.ms-excel " ; break ;
case " ppt " : $ctype = " application/vnd.ms-powerpoint " ; break ;
case " gif " : $ctype = " image/gif " ; break ;
case " png " : $ctype = " image/png " ; break ;
case " jpeg " :
case " jpg " : $ctype = " image/jpg " ; break ;
default : $ctype = " application/force-download " ;
}
$content = file_get_contents ( $fullPath );
$this -> _helper -> layout -> disableLayout ();
$this -> _helper -> viewRenderer -> setNoRender ();
$this -> getResponse () -> setHeader ( 'Content-Type' , 'application/octet-stream' )
-> setHeader ( 'Content-Disposition' , 'attachment; filename="' . $row [ 'realname' ] . '"' )
-> setHeader ( 'Content-Length' , $fsize )
-> setHeader ( 'Content-Type' , 'application/force-download' )
-> setHeader ( 'Content-Type' , 'application/download' )
-> setHeader ( 'Content-Type' , $ctype )
-> 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 );
$sql = " update attachments set downtimes=downtimes+1 where id = $id " ;
@ $this -> db -> exec ( $sql );
} catch ( Exception $e ){
2011-11-09 07:57:50 +00:00
echo ' <! DOCTYPE html PUBLIC " -//W3C//DTD XHTML 1.0 Transitional//EN " " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
< html xmlns = " http://www.w3.org/1999/xhtml " >
2011-11-14 02:54:10 +00:00
< head >< meta http - equiv = " Content-Type " content = " text/html; charset=utf-8 " />
< title > 错误提示! </ title ></ head >< body > 文件读取出错,请稍后重试 </ body ></ html > ' ;
exit ();
2011-11-08 08:04:11 +00:00
}
} else {
2011-11-09 07:57:50 +00:00
echo ' <! DOCTYPE html PUBLIC " -//W3C//DTD XHTML 1.0 Transitional//EN " " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
< html xmlns = " http://www.w3.org/1999/xhtml " >
2011-11-14 02:54:10 +00:00
< head >< meta http - equiv = " Content-Type " content = " text/html; charset=utf-8 " />
< title > 错误提示! </ title ></ head >< body > 读取用户信息出错,请先登录再下载附件重试 </ body ></ html > ' ;
exit ();
2011-11-08 08:04:11 +00:00
}
2011-11-08 07:09:23 +00:00
} // downattAction 下载附件
2013-05-03 06:41:06 +00:00
2012-01-13 09:12:02 +00:00
/*
* denyinviteAction () 专家拒绝邀请
*
* @ param id int //用户ID
* @ param uuid uuid //元数据UUID
*
* return view -> message
*
* 要求专家后会发送通知邮件到专家邮箱,邮箱中包含拒绝邀请的链接
* 链接地址 / review / denyinvite / id / { userid } / uuid / { uuid }
*/
2011-12-01 02:24:37 +00:00
function denyinviteAction ()
2011-11-23 10:24:07 +00:00
{
2013-05-03 06:41:06 +00:00
include_once ( " helper/view.php " );
2011-11-15 08:54:42 +00:00
$id = $this -> _request -> getParam ( 'id' );
$uuid = $this -> _request -> getParam ( 'uuid' );
if ( empty ( $id ) || empty ( $uuid ) || ! is_numeric ( $id ) ||! preg_match ( " /^[0-9A-Za-z] { 8}-[0-9A-Za-z] { 4}-[0-9A-Za-z] { 4}-[0-9A-Za-z] { 4}-[0-9A-Za-z] { 12} $ / " , $uuid ))
{
2013-05-03 06:41:06 +00:00
view :: Post ( $this , array ( 'pageTitle' => '提示信息' , 'content' => '参数错误' , 'url' => '/' ));
return true ;
2011-11-15 08:54:42 +00:00
} else {
$auth = Zend_Auth :: getInstance ();
if ( $auth -> hasIdentity ())
{
$user = $auth -> getIdentity ();
$userid = $user -> id ;
if ( $id == $userid )
{
try {
2011-11-23 10:24:07 +00:00
$sql = " update mdexpertreview set status=-1 where id=' $id ' and uuid=' $uuid ' " ;
if ( $this -> db -> exec ( $sql ))
2013-05-03 06:41:06 +00:00
{
view :: Post ( $this , array ( 'pageTitle' => '提示信息' , 'content' => '您已经拒绝该元数据的评审邀请' , 'url' => '/' ));
return true ;
}
2011-12-01 02:24:37 +00:00
else
2013-05-03 06:41:06 +00:00
{
view :: Post ( $this , array ( 'pageTitle' => '提示信息' , 'content' => '您无权执行此操作' , 'url' => '/' ));
return true ;
}
2011-11-15 08:54:42 +00:00
} catch ( Exception $e ){
$this -> view -> message = $e -> getMessage ();
}
} //end if
else
{
2013-05-03 06:41:06 +00:00
view :: Post ( $this , array ( 'pageTitle' => '提示信息' , 'content' => '您无权使用此通知' , 'url' => '/' ));
return true ;
2011-11-15 08:54:42 +00:00
} //非本人操作,或尝试删除他人信息
} //end if
else
{
2013-05-03 06:41:06 +00:00
view :: Post ( $this , array ( 'pageTitle' => '提示信息' , 'content' => '请登录后再执行此操作' , 'url' => '/account/login/?href=/review/allowinvite/id/' . $id . '/uuid/' . $uuid ));
return true ;
2011-11-15 08:54:42 +00:00
} //未登录
}
} // denyinviteAction() 专家拒绝邀请
2013-05-03 06:41:06 +00:00
//parameters are same as denyinviteAction
function inviteokAction ()
{
include_once ( " helper/view.php " );
$id = $this -> _request -> getParam ( 'id' );
$uuid = $this -> _request -> getParam ( 'uuid' );
$auth = Zend_Auth :: getInstance ();
if ( $auth -> hasIdentity ())
{
$user = $auth -> getIdentity ();
$userid = $user -> id ;
include_once ( " data/Review.php " );
$review = new Review ( $this -> db );
$s = $review -> invite ( $id , $uuid , $userid , 1 );
if ( $s == true )
{
view :: Post ( $this , array ( 'content' => '您已经接受邀请' , 'url' => '/review/review/uuid/' . $uuid ));
return true ;
} else {
view :: Post ( $this , array ( 'content' => $s ));
return true ;
}
} else {
view :: Post ( $this , array ( 'content' => '请登录后再执行此操作' , 'url' => '/account/login/?href=/review/allowinvite/id/' . $id . '/uuid/' . $uuid ));
return true ;
} //未登录
} //allowinviteAction()
2011-10-13 07:56:18 +00:00
}