2012-02-22 12:21:22 +00:00
|
|
|
|
<?php
|
2012-03-06 08:06:54 +00:00
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
@version $Id: AuthorController.php 2012-2-29 15:01 Z
|
|
|
|
|
@package author
|
|
|
|
|
@copyright Copyright (c) 2012, CAREERI.
|
|
|
|
|
@license http://
|
|
|
|
|
@link http://
|
|
|
|
|
|
2012-03-09 09:03:50 +00:00
|
|
|
|
@update 2012-3-1 15:06 李建轩
|
|
|
|
|
@update 2012-3-9 17:01 李建轩
|
2012-03-12 08:44:20 +00:00
|
|
|
|
@update 2012-3-12 16:16 李建轩
|
2012-03-20 09:34:44 +00:00
|
|
|
|
@update 2012-3-14 18:01 李建轩
|
2012-03-21 03:28:12 +00:00
|
|
|
|
@update 2012-3-21 10:58 李建轩
|
2012-03-06 08:06:54 +00:00
|
|
|
|
|
|
|
|
|
*/
|
2012-02-22 12:21:22 +00:00
|
|
|
|
class AuthorController extends Zend_Controller_Action
|
|
|
|
|
{
|
|
|
|
|
private $limit=10;
|
2012-03-12 08:44:20 +00:00
|
|
|
|
|
|
|
|
|
//调试模式
|
|
|
|
|
// 调试模式中将显示全部错误细节,电子邮件将发往调试邮箱
|
|
|
|
|
// 1 为开启
|
|
|
|
|
// 0 为关闭
|
|
|
|
|
public $debug = 1;
|
|
|
|
|
|
|
|
|
|
//调试模式邮箱地址
|
|
|
|
|
public $debug_email = "la5c@qq.com";
|
|
|
|
|
|
|
|
|
|
|
2012-02-22 12:21:22 +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();
|
|
|
|
|
}
|
|
|
|
|
function indexAction()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-03-09 09:03:50 +00:00
|
|
|
|
/*
|
|
|
|
|
* helpAction() 帮助文档
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
function helpAction(){
|
|
|
|
|
|
|
|
|
|
}//helpAction()帮助文档
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* inauthorAction() 数据申请管理
|
|
|
|
|
*
|
|
|
|
|
* param string $ac
|
|
|
|
|
* param string $keywords
|
|
|
|
|
* param string $pr //对离线数据申请的操作
|
|
|
|
|
* param string $uuid
|
|
|
|
|
*
|
|
|
|
|
* return view|ajax-responds
|
|
|
|
|
*/
|
|
|
|
|
function inauthorAction()
|
2012-02-22 12:21:22 +00:00
|
|
|
|
{
|
2012-03-09 09:03:50 +00:00
|
|
|
|
|
|
|
|
|
$ac = $this->_request->getParam("ac");
|
|
|
|
|
|
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
|
if($auth->hasIdentity())
|
|
|
|
|
{
|
|
|
|
|
$user = $auth->getIdentity();
|
|
|
|
|
$u_id = $user->id;
|
|
|
|
|
$u_email = $user->email;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(empty($ac) || $ac=="online")
|
|
|
|
|
{
|
|
|
|
|
$sql = "SELECT o.id,o.userid,o.unit,o.username,o.ts_created,o.project,m.title,m.uuid FROM onlineapp as o
|
|
|
|
|
LEFT JOIN metadata as m ON o.uuid=m.uuid
|
|
|
|
|
LEFT JOIN mdauthor as a ON a.uuid=o.uuid
|
2012-03-12 08:44:20 +00:00
|
|
|
|
WHERE (o.id in (SELECT distinct(onlineappid) from dataorder)) AND a.userid = ? AND a.status=1
|
2012-03-09 09:03:50 +00:00
|
|
|
|
ORDER BY o.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(10);
|
|
|
|
|
$paginator->setView($this->view);
|
|
|
|
|
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
|
|
|
|
$this->view->paginator=$paginator;
|
|
|
|
|
}//在线申请记录
|
|
|
|
|
|
|
|
|
|
if($ac == "searchonline")
|
|
|
|
|
{
|
|
|
|
|
$keywords = $this->_request->getParam('q');
|
|
|
|
|
if(!empty($keywords))
|
|
|
|
|
{
|
|
|
|
|
$this->view->q = $keywords;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sql = "SELECT o.id,o.userid,o.unit,o.username,o.ts_created,o.project,m.title,m.uuid FROM onlineapp as o
|
|
|
|
|
LEFT JOIN metadata as m ON o.uuid=m.uuid
|
|
|
|
|
LEFT JOIN mdauthor as a ON a.uuid=o.uuid
|
2012-03-12 08:44:20 +00:00
|
|
|
|
WHERE (o.id in (SELECT distinct(onlineappid) from dataorder)) AND a.userid = ? AND (m.title like ? or m.description like ?) AND a.status=1
|
2012-03-09 09:03:50 +00:00
|
|
|
|
ORDER BY o.id desc";
|
|
|
|
|
|
|
|
|
|
$sth = $this->db->prepare($sql);
|
|
|
|
|
$sth->execute(array($u_id,"%$keywords%","%$keywords%"));
|
|
|
|
|
$rows = $sth->fetchAll();
|
|
|
|
|
|
|
|
|
|
$paginator = Zend_Paginator::factory($rows);
|
|
|
|
|
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
|
|
|
|
$paginator->setItemCountPerPage(10);
|
|
|
|
|
$paginator->setView($this->view);
|
|
|
|
|
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
|
|
|
|
$this->view->paginator=$paginator;
|
|
|
|
|
|
|
|
|
|
}//在线申请记录搜索
|
|
|
|
|
|
|
|
|
|
if($ac == "offline")
|
|
|
|
|
{
|
|
|
|
|
$pr = $this->_request->getParam('pr');
|
2012-03-12 03:14:50 +00:00
|
|
|
|
$oid = $this->_request->getParam('oid');
|
2012-03-09 09:03:50 +00:00
|
|
|
|
|
|
|
|
|
if(!empty($pr))
|
|
|
|
|
{
|
|
|
|
|
try{
|
|
|
|
|
$this->_helper->layout->disableLayout();
|
|
|
|
|
$this->_helper->viewRenderer->setNoRender();
|
|
|
|
|
|
|
|
|
|
$uuid = $this->_request->getParam('uuid');
|
2012-03-12 03:14:50 +00:00
|
|
|
|
|
2012-03-09 09:03:50 +00:00
|
|
|
|
if(!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))
|
|
|
|
|
{
|
|
|
|
|
echo "参数有误!";exit();
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-12 03:14:50 +00:00
|
|
|
|
//如果用户已经下载过了,就无法在更改对数据申请的意见
|
2012-03-09 09:03:50 +00:00
|
|
|
|
$sql = "select md.title,d.uuid,d.status as datastatus,d.authorpermitted from offlineapp o
|
|
|
|
|
left join dataorder d on o.id=d.offlineappid
|
|
|
|
|
left join metadata md on md.uuid=d.uuid
|
2012-03-09 09:29:26 +00:00
|
|
|
|
left join mdauthor a on a.uuid=d.uuid
|
2012-03-12 08:44:20 +00:00
|
|
|
|
where o.ts_approved is null and o.pdflink is not null and d.uuid=? and a.userid=? and d.offlineappid=? AND a.status=1
|
2012-03-09 09:03:50 +00:00
|
|
|
|
order by o.ts_created desc";
|
|
|
|
|
|
|
|
|
|
$sth = $this->db->prepare($sql);
|
2012-03-12 03:14:50 +00:00
|
|
|
|
$sth->execute(array($uuid,$u_id,$oid));
|
2012-03-09 09:03:50 +00:00
|
|
|
|
$row = $sth->fetch();
|
|
|
|
|
|
|
|
|
|
if($row['datastatus']>4)
|
|
|
|
|
{
|
|
|
|
|
echo "该申请已经通过并且发放数据";
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-12 03:14:50 +00:00
|
|
|
|
//同意用户下载
|
2012-03-09 09:03:50 +00:00
|
|
|
|
if($pr=="confrim")
|
|
|
|
|
{
|
2012-03-12 03:14:50 +00:00
|
|
|
|
$sql = "UPDATE dataorder SET authorpermitted=1 WHERE uuid=? AND offlineappid=?";
|
2012-03-09 09:03:50 +00:00
|
|
|
|
$sth = $this->db->prepare($sql);
|
2012-03-12 03:14:50 +00:00
|
|
|
|
if($sth->execute(array($uuid,$oid)))
|
2012-03-09 09:03:50 +00:00
|
|
|
|
{
|
2012-03-12 03:14:50 +00:00
|
|
|
|
$btn = $this->createOfflineCtBtn($uuid,'c',$oid);
|
2012-03-09 09:03:50 +00:00
|
|
|
|
echo ''.$btn.'<script>alert("您已经同意用户的离线数据申请");</script>';
|
|
|
|
|
exit();
|
|
|
|
|
}else{
|
|
|
|
|
echo "<script>alert('处理过程中遇到错误,请刷新页面');</script>";
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-12 03:14:50 +00:00
|
|
|
|
|
|
|
|
|
//反对用户下载
|
2012-03-09 09:03:50 +00:00
|
|
|
|
if($pr == "objection")
|
|
|
|
|
{
|
2012-03-12 03:14:50 +00:00
|
|
|
|
$sql = "UPDATE dataorder SET authorpermitted=-1 WHERE uuid=? AND offlineappid=?";
|
2012-03-09 09:03:50 +00:00
|
|
|
|
$sth = $this->db->prepare($sql);
|
2012-03-12 03:14:50 +00:00
|
|
|
|
if($sth->execute(array($uuid,$oid)))
|
2012-03-09 09:03:50 +00:00
|
|
|
|
{
|
2012-03-12 03:14:50 +00:00
|
|
|
|
$btn = $this->createOfflineCtBtn($uuid,'o',$oid);
|
2012-03-09 09:03:50 +00:00
|
|
|
|
echo ''.$btn.'<script>alert("您已经反对用户的离线数据申请");</script>';
|
|
|
|
|
exit();
|
|
|
|
|
}else{
|
|
|
|
|
echo "<script>alert('处理过程中遇到错误,请刷新页面');</script>";
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}catch(Exception $e)
|
|
|
|
|
{
|
|
|
|
|
echo "处理中遇到错误,请刷新页面后重试";
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$this->_helper->viewRenderer('inauthor-offline');
|
|
|
|
|
|
|
|
|
|
$select="select distinct(o.*),md.title,d.uuid,d.status as datastatus,d.authorpermitted from offlineapp o
|
|
|
|
|
left join dataorder d on o.id=d.offlineappid
|
|
|
|
|
left join metadata md on md.uuid=d.uuid
|
2012-03-09 09:29:26 +00:00
|
|
|
|
left join mdauthor a on a.uuid=d.uuid
|
2012-03-12 08:44:20 +00:00
|
|
|
|
where o.ts_approved is null and o.pdflink is not null and d.status=4 and a.userid=? AND a.status=1
|
2012-03-09 09:03:50 +00:00
|
|
|
|
order by o.ts_created desc";
|
|
|
|
|
|
|
|
|
|
$sth = $this->db->prepare($select);
|
2012-03-09 09:29:26 +00:00
|
|
|
|
$sth->execute(array($u_id));
|
2012-03-09 09:03:50 +00:00
|
|
|
|
$rows = $sth->fetchAll();
|
|
|
|
|
|
|
|
|
|
foreach ($rows as $k=>$v)
|
|
|
|
|
{
|
|
|
|
|
if($v['authorpermitted']==0)
|
2012-03-12 03:14:50 +00:00
|
|
|
|
{$rows[$k]['btns']=$this->createOfflineCtBtn($v['uuid'],'',$v['id']);}
|
2012-03-09 09:03:50 +00:00
|
|
|
|
if($v['authorpermitted']>0)
|
2012-03-12 03:14:50 +00:00
|
|
|
|
{$rows[$k]['btns']=$this->createOfflineCtBtn($v['uuid'],'c',$v['id']);}
|
2012-03-09 09:03:50 +00:00
|
|
|
|
if($v['authorpermitted']<0)
|
2012-03-12 03:14:50 +00:00
|
|
|
|
{$rows[$k]['btns']=$this->createOfflineCtBtn($v['uuid'],'o',$v['id']);}
|
2012-03-09 09:03:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$paginator = Zend_Paginator::factory($rows);
|
|
|
|
|
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
|
|
|
|
$paginator->setItemCountPerPage(10);
|
|
|
|
|
$paginator->setView($this->view);
|
|
|
|
|
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
|
|
|
|
$this->view->paginator=$paginator;
|
|
|
|
|
}
|
|
|
|
|
}//离线申请
|
|
|
|
|
|
|
|
|
|
if($ac == "searchoffline")
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
$keywords = $this->_request->getParam('q');
|
|
|
|
|
if(!empty($keywords))
|
|
|
|
|
{
|
|
|
|
|
$this->view->q = $keywords;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->_helper->viewRenderer('inauthor-offline');
|
|
|
|
|
|
|
|
|
|
$select="select distinct(o.*),md.title,md.description,d.uuid,d.status as datastatus,d.authorpermitted from offlineapp o
|
|
|
|
|
left join dataorder d on o.id=d.offlineappid
|
|
|
|
|
left join metadata md on md.uuid=d.uuid
|
2012-03-09 09:29:26 +00:00
|
|
|
|
left join mdauthor a on a.uuid=d.uuid
|
2012-03-12 08:44:20 +00:00
|
|
|
|
where o.ts_approved is null and o.pdflink is not null and d.status=4 and (md.title like ? or md.description like ?) and a.userid=? AND a.status=1
|
2012-03-09 09:03:50 +00:00
|
|
|
|
order by o.ts_created desc";
|
|
|
|
|
|
|
|
|
|
$sth = $this->db->prepare($select);
|
2012-03-09 09:29:26 +00:00
|
|
|
|
$sth->execute(array("%$keywords%","%$keywords%",$u_id));
|
2012-03-09 09:03:50 +00:00
|
|
|
|
$rows = $sth->fetchAll();
|
|
|
|
|
|
|
|
|
|
foreach ($rows as $k=>$v)
|
|
|
|
|
{
|
|
|
|
|
if($v['authorpermitted']==0)
|
2012-03-12 03:14:50 +00:00
|
|
|
|
{$rows[$k]['btns']=$this->createOfflineCtBtn($v['uuid'],'',$v['id']);}
|
2012-03-09 09:03:50 +00:00
|
|
|
|
if($v['authorpermitted']>0)
|
2012-03-12 03:14:50 +00:00
|
|
|
|
{$rows[$k]['btns']=$this->createOfflineCtBtn($v['uuid'],'c',$v['id']);}
|
2012-03-09 09:03:50 +00:00
|
|
|
|
if($v['authorpermitted']<0)
|
2012-03-12 03:14:50 +00:00
|
|
|
|
{$rows[$k]['btns']=$this->createOfflineCtBtn($v['uuid'],'o',$v['id']);}
|
2012-03-09 09:03:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$paginator = Zend_Paginator::factory($rows);
|
|
|
|
|
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
|
|
|
|
$paginator->setItemCountPerPage(10);
|
|
|
|
|
$paginator->setView($this->view);
|
|
|
|
|
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
|
|
|
|
$this->view->paginator=$paginator;
|
|
|
|
|
}//离线申请搜索
|
|
|
|
|
|
|
|
|
|
} // inauthorAction() 数据申请管理
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* createOfflineCtBtn() 创建离线申请记录的操作按钮
|
|
|
|
|
*
|
|
|
|
|
*/
|
2012-03-12 03:14:50 +00:00
|
|
|
|
function createOfflineCtBtn($uuid, $type="",$oid){
|
2012-03-09 09:03:50 +00:00
|
|
|
|
$urlHref = 'href="javascript:;"';
|
|
|
|
|
$baseStyle = "offline-ct-btns box-shadow";
|
|
|
|
|
$selectedStyle = "offline-select";
|
|
|
|
|
|
|
|
|
|
$confrimText = "同意";
|
2012-03-12 03:14:50 +00:00
|
|
|
|
$confrimFunc = 'onclick="confrim(\''.$uuid.'\',\''.$oid.'\')"';
|
2012-03-09 09:03:50 +00:00
|
|
|
|
|
|
|
|
|
$objectionText = "反对";
|
2012-03-12 03:14:50 +00:00
|
|
|
|
$objectionFunc = 'onclick="objection(\''.$uuid.'\',\''.$oid.'\')"';
|
2012-03-09 09:03:50 +00:00
|
|
|
|
|
|
|
|
|
$btns='';
|
|
|
|
|
if(empty($type))
|
|
|
|
|
{
|
|
|
|
|
$confrimBtn = "<a $urlHref class=\"$baseStyle\" $confrimFunc>$confrimText</a>";
|
|
|
|
|
$objectionBtn = "<a $urlHref class=\"$baseStyle\" $objectionFunc>$objectionText</a>";
|
|
|
|
|
$btns = $confrimBtn.$objectionBtn;
|
|
|
|
|
}
|
|
|
|
|
if($type=='c')
|
|
|
|
|
{
|
|
|
|
|
$confrimBtn = "<a class=\"$baseStyle $selectedStyle\">$confrimText</a>";
|
|
|
|
|
$objectionBtn = "<a $urlHref class=\"$baseStyle\" $objectionFunc>$objectionText</a>";
|
|
|
|
|
$btns = $confrimBtn.$objectionBtn;
|
|
|
|
|
}
|
|
|
|
|
if($type=='o')
|
|
|
|
|
{
|
|
|
|
|
$confrimBtn = "<a $urlHref class=\"$baseStyle\" $confrimFunc>$confrimText</a>";
|
|
|
|
|
$objectionBtn = "<a class=\"$baseStyle $selectedStyle\">$objectionText</a>";
|
|
|
|
|
$btns = $confrimBtn.$objectionBtn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $btns;
|
|
|
|
|
|
|
|
|
|
} //createOfflineCtBtn()
|
|
|
|
|
|
|
|
|
|
|
2012-02-22 12:21:22 +00:00
|
|
|
|
|
2012-03-06 08:06:54 +00:00
|
|
|
|
/*
|
|
|
|
|
* acceptAction() 我的数据
|
|
|
|
|
*
|
2012-03-07 07:43:37 +00:00
|
|
|
|
* param string $ac // list|search
|
|
|
|
|
* param string $keyword
|
2012-03-06 08:06:54 +00:00
|
|
|
|
*
|
2012-03-07 07:43:37 +00:00
|
|
|
|
* return view
|
2012-03-06 08:06:54 +00:00
|
|
|
|
*/
|
|
|
|
|
function acceptAction()
|
|
|
|
|
{
|
2012-03-07 03:48:40 +00:00
|
|
|
|
$ac = $this->_request->getParam("ac");
|
|
|
|
|
|
2012-03-06 08:06:54 +00:00
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
|
if($auth->hasIdentity())
|
|
|
|
|
{
|
|
|
|
|
$user = $auth->getIdentity();
|
|
|
|
|
$u_id = $user->id;
|
2012-03-07 03:48:40 +00:00
|
|
|
|
$u_email = $user->email;
|
2012-03-06 08:06:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-03-07 03:48:40 +00:00
|
|
|
|
//列表
|
|
|
|
|
if(empty($ac) || $ac=='list'){
|
|
|
|
|
|
2012-03-21 03:45:03 +00:00
|
|
|
|
$sql = "SELECT a.*,m.title,m.description FROM normalmetadata m
|
|
|
|
|
LEFT JOIN mdauthor a ON m.uuid=a.uuid
|
|
|
|
|
WHERE a.userid=? AND status>=0
|
|
|
|
|
ORDER BY status DESC,a.id DESC
|
2012-03-07 03:48:40 +00:00
|
|
|
|
";
|
|
|
|
|
|
|
|
|
|
$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(5);
|
|
|
|
|
$paginator->setView($this->view);
|
|
|
|
|
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
|
|
|
|
$this->view->paginator=$paginator;
|
|
|
|
|
|
|
|
|
|
}//list
|
|
|
|
|
|
|
|
|
|
//搜索
|
|
|
|
|
if($ac == "search")
|
|
|
|
|
{
|
2012-03-07 07:43:37 +00:00
|
|
|
|
$keyword = trim($this->_request->getParam('q'));
|
|
|
|
|
$this->view->q = $keyword;
|
|
|
|
|
if (!preg_match_all("/^[\x{4e00}-\x{9fa5}A-Za-z0-9_]+$/u",$keyword,$matchs))
|
|
|
|
|
{
|
|
|
|
|
$data = array('error'=>'搜索关键字中只能包含汉字、英文、数字');
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//搜索标题和描述两个字段
|
2012-03-21 03:45:03 +00:00
|
|
|
|
$sql = "SELECT a.*,m.title,m.description FROM normalmetadata m
|
|
|
|
|
LEFT JOIN mdauthor a ON m.uuid=a.uuid
|
|
|
|
|
WHERE (m.title like ? OR m.description like ?) AND a.userid=? AND status>=0
|
|
|
|
|
ORDER BY status DESC,a.id DESC
|
|
|
|
|
";
|
2012-03-07 07:43:37 +00:00
|
|
|
|
$sth = $this->db->prepare($sql);
|
|
|
|
|
$sth->execute(array("%$keyword%","%$keyword%",$u_id));
|
|
|
|
|
$rows = $sth->fetchAll();
|
2012-03-07 03:48:40 +00:00
|
|
|
|
|
2012-03-07 07:43:37 +00:00
|
|
|
|
$paginator = Zend_Paginator::factory($rows);
|
|
|
|
|
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
|
|
|
|
$paginator->setItemCountPerPage(5);
|
|
|
|
|
$paginator->setView($this->view);
|
|
|
|
|
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
|
|
|
|
$this->view->paginator=$paginator;
|
|
|
|
|
}
|
2012-03-07 03:48:40 +00:00
|
|
|
|
}// search
|
2012-03-12 08:44:20 +00:00
|
|
|
|
|
2012-03-20 09:34:44 +00:00
|
|
|
|
//激活数据作者
|
2012-03-12 08:44:20 +00:00
|
|
|
|
if($ac == "active")
|
|
|
|
|
{
|
|
|
|
|
$this->_helper->viewRenderer('accept-active');
|
|
|
|
|
$vdcode = $this->_request->getParam('v');
|
|
|
|
|
$this->view->v = $vdcode;
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
$sql = "SELECT a.id,a.activation,a.ts_created,a.ts_activated,md.title,a.uuid,u.realname,u.email FROM mdauthor a
|
|
|
|
|
LEFT JOIN metadata md ON a.uuid=md.uuid
|
|
|
|
|
LEFT JOIN users u ON a.userid=u.id
|
2012-03-20 09:34:44 +00:00
|
|
|
|
WHERE a.activation=?";
|
2012-03-12 08:44:20 +00:00
|
|
|
|
|
|
|
|
|
$sth = $this->db->prepare($sql);
|
2012-03-20 09:34:44 +00:00
|
|
|
|
$sth->execute(array($vdcode));
|
2012-03-12 08:44:20 +00:00
|
|
|
|
$row = $sth->fetch();
|
|
|
|
|
|
2012-03-20 09:34:44 +00:00
|
|
|
|
if(empty($row['id']))
|
2012-03-12 08:44:20 +00:00
|
|
|
|
{
|
2012-03-20 09:34:44 +00:00
|
|
|
|
$this->view->info='此激活码无效';
|
2012-03-12 08:44:20 +00:00
|
|
|
|
}else{
|
|
|
|
|
if(empty($row['ts_activated']))
|
|
|
|
|
{
|
|
|
|
|
$sql = "UPDATE mdauthor SET ts_activated=?,status=? WHERE activation=?";
|
|
|
|
|
|
|
|
|
|
$sth = $this->db->prepare($sql);
|
|
|
|
|
$ex = $sth->execute(array('now()',1,$vdcode));
|
|
|
|
|
|
|
|
|
|
if($ex)
|
|
|
|
|
{
|
|
|
|
|
include_once("EmailText.php");
|
|
|
|
|
$mail=new WestdcMailer($this->view->config->smtp);
|
|
|
|
|
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
2012-03-21 02:56:50 +00:00
|
|
|
|
$mailtp=new EmailText($this->db,"author-new",array(
|
2012-03-12 08:44:20 +00:00
|
|
|
|
'user' => $row['realname'],
|
|
|
|
|
'uuid' => $row['uuid'],
|
|
|
|
|
'title'=> $row['title'],
|
|
|
|
|
'email'=> $row['email'],
|
|
|
|
|
));
|
|
|
|
|
$mail->setBodyText($mailtp->getBody());
|
|
|
|
|
$mail->setSubject($mailtp->getSubject());
|
|
|
|
|
if($this->debug==0)
|
|
|
|
|
{
|
|
|
|
|
//获得元数据作者email
|
2012-03-21 02:56:50 +00:00
|
|
|
|
/* 不需要给这些人发通知邮件
|
2012-03-20 09:34:44 +00:00
|
|
|
|
$info = $this->getEmail($uuid,1);
|
|
|
|
|
|
|
|
|
|
$address = $info['addrs'];
|
|
|
|
|
foreach($address as $v)
|
2012-03-12 08:44:20 +00:00
|
|
|
|
{
|
2012-03-20 09:34:44 +00:00
|
|
|
|
$mail->addTo($v);
|
2012-03-21 02:56:50 +00:00
|
|
|
|
}*/
|
2012-03-12 08:44:20 +00:00
|
|
|
|
$mail->addTo($row['email']);
|
|
|
|
|
$mail->addCc($this->view->config->service->email); //管理员
|
|
|
|
|
}else{
|
|
|
|
|
$mail->addTo($this->debug_email);
|
|
|
|
|
}
|
|
|
|
|
$mail->send();
|
|
|
|
|
$this->view->info = '激活成功<br /><a href="/author/accept">点击这里</a>进入我的数据页面查看';
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
$this->view->info = "激活中遇到问题,请重试";
|
|
|
|
|
}
|
|
|
|
|
}else
|
|
|
|
|
{
|
2012-03-20 09:34:44 +00:00
|
|
|
|
$this->view->info='此激活码已经失效';
|
2012-03-12 08:44:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
if($this->debug==0)
|
|
|
|
|
{
|
|
|
|
|
$this->view->info = "处理中遇到错误,请重新尝试";
|
|
|
|
|
}else{
|
|
|
|
|
$this->view->info = $e->getMessage();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-20 09:34:44 +00:00
|
|
|
|
}//激活数据作者
|
|
|
|
|
|
|
|
|
|
//否认激活
|
|
|
|
|
if($ac == "lock")
|
|
|
|
|
{
|
|
|
|
|
$this->_helper->viewRenderer('accept-active');
|
|
|
|
|
$vdcode = $this->_request->getParam('v');
|
|
|
|
|
$this->view->v = $vdcode;
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
$sql = "SELECT a.id,a.activation,a.ts_created,a.ts_activated,md.title,a.uuid,u.realname,u.email FROM mdauthor a
|
|
|
|
|
LEFT JOIN metadata md ON a.uuid=md.uuid
|
|
|
|
|
LEFT JOIN users u ON a.userid=u.id
|
|
|
|
|
WHERE a.activation=?";
|
|
|
|
|
|
|
|
|
|
$sth = $this->db->prepare($sql);
|
|
|
|
|
$sth->execute(array($vdcode));
|
|
|
|
|
$row = $sth->fetch();
|
|
|
|
|
|
|
|
|
|
if(empty($row['id']))
|
|
|
|
|
{
|
|
|
|
|
$this->view->info='此激活码无效';
|
|
|
|
|
}else{
|
|
|
|
|
if(empty($row['ts_activated']))
|
|
|
|
|
{
|
|
|
|
|
$sql = "UPDATE mdauthor SET ts_activated=?,status=? WHERE activation=?";
|
|
|
|
|
|
|
|
|
|
$sth = $this->db->prepare($sql);
|
|
|
|
|
$ex = $sth->execute(array('now()',-1,$vdcode));
|
|
|
|
|
|
|
|
|
|
if($ex)
|
|
|
|
|
{
|
|
|
|
|
include_once("EmailText.php");
|
|
|
|
|
$mail=new WestdcMailer($this->view->config->smtp);
|
|
|
|
|
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
|
|
|
|
$mailtp=new EmailText($this->db,"author-deny",array(
|
|
|
|
|
'user' => $row['realname'],
|
|
|
|
|
'uuid' => $row['uuid'],
|
|
|
|
|
'title'=> $row['title'],
|
|
|
|
|
'email'=> $row['email'],
|
|
|
|
|
));
|
|
|
|
|
$mail->setBodyText($mailtp->getBody());
|
|
|
|
|
$mail->setSubject($mailtp->getSubject());
|
|
|
|
|
if($this->debug==0)
|
|
|
|
|
{
|
2012-03-21 03:28:12 +00:00
|
|
|
|
$mail->addTo($row['email']);
|
2012-03-21 02:56:50 +00:00
|
|
|
|
$mail->addCc($this->view->config->service->email);
|
2012-03-20 09:34:44 +00:00
|
|
|
|
}else{
|
|
|
|
|
$mail->addTo($this->debug_email);
|
|
|
|
|
}
|
|
|
|
|
$mail->send();
|
|
|
|
|
$this->view->info = '该申请已被拒绝,<a href="/author/accept">点击这里</a>进入我的数据页面查看';
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
$this->view->info = "激活中遇到问题,请重试";
|
|
|
|
|
}
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
$this->view->info='此激活码已经失效';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
if($this->debug==0)
|
|
|
|
|
{
|
|
|
|
|
$this->view->info = "处理中遇到错误,请重新尝试";
|
|
|
|
|
}else{
|
|
|
|
|
$this->view->info = $e->getMessage();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}//否认激活
|
2012-03-07 03:48:40 +00:00
|
|
|
|
|
2012-03-06 08:06:54 +00:00
|
|
|
|
}//acceptAction() 我的数据
|
|
|
|
|
|
|
|
|
|
|
2012-03-20 09:34:44 +00:00
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
* getEmail() 获取数据所有者电子邮箱地址
|
|
|
|
|
*
|
|
|
|
|
* param string $uuid //UUID
|
|
|
|
|
* param int $level //输出信息等级
|
|
|
|
|
* 0 => 输出所有Email地址
|
|
|
|
|
* 1 => 输出数据权限等级最高的Email地址 (def)
|
|
|
|
|
*
|
|
|
|
|
* return array()
|
|
|
|
|
*/
|
|
|
|
|
function getEmail($uuid,$level=1)
|
|
|
|
|
{
|
|
|
|
|
//需要定义角色,防止程序流程出错
|
|
|
|
|
$addrs = array();
|
|
|
|
|
$addrs['resourceProvider'] = array();
|
|
|
|
|
$addrs['owner'] = array();
|
|
|
|
|
$addrs['pointOfContact'] = array();
|
|
|
|
|
$addrs['author'] = array();
|
|
|
|
|
$addrs["publisher"] = array();
|
|
|
|
|
|
2012-03-21 02:56:50 +00:00
|
|
|
|
$sql = 'select r.uuid,p.email,md.title,r.role from normalmetadata md
|
2012-03-20 09:34:44 +00:00
|
|
|
|
LEFT JOIN role r ON md.uuid=r.uuid
|
|
|
|
|
left join responsible p on r.resid=p.id
|
|
|
|
|
WHERE r.uuid=? AND p.email IS NOT NULL AND p.email!=?
|
|
|
|
|
GROUP BY r.uuid,p.email,md.title,r.role';
|
|
|
|
|
$sth = $this->db->prepare($sql);
|
|
|
|
|
$sth->execute(array($uuid,''));
|
|
|
|
|
$rows = $sth->fetchAll();
|
|
|
|
|
|
|
|
|
|
$addrs['title'] = $rows[0]['title'];
|
|
|
|
|
|
|
|
|
|
foreach($rows as $k=>$v)
|
|
|
|
|
{
|
|
|
|
|
//数据资源提供者resourceProvider
|
|
|
|
|
if($v['role']=='resourceProvider')
|
|
|
|
|
{
|
|
|
|
|
$addrs['resourceProvider'][]=$v['email'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//数据资源所有者owner
|
|
|
|
|
if($v['role']=='owner')
|
|
|
|
|
{
|
|
|
|
|
$addrs['owner'][]=$v['email'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//数据联系人pointOfContact
|
|
|
|
|
if($v['role']=='pointOfContact')
|
|
|
|
|
{
|
|
|
|
|
$addrs['pointOfContact'][]=$v['email'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//元数据作者author
|
|
|
|
|
if($v['role']== 'author' )
|
|
|
|
|
{
|
|
|
|
|
$addrs['author'][] = $v['email'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($v["role"] =="")
|
|
|
|
|
{
|
|
|
|
|
$addrs["publisher"][] = $v['email'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-21 02:56:50 +00:00
|
|
|
|
//输出所有email (多维数组)
|
2012-03-20 09:34:44 +00:00
|
|
|
|
/*
|
|
|
|
|
$addrs['resourceProvider']
|
|
|
|
|
$addrs['owner']
|
|
|
|
|
$addrs['pointOfContact']
|
|
|
|
|
$addrs['author']
|
|
|
|
|
*/
|
|
|
|
|
if($level == 0)
|
|
|
|
|
{
|
|
|
|
|
return $addrs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//输出最高优先级的Email
|
|
|
|
|
//$addrs['addrs']
|
|
|
|
|
if($level == 1)
|
|
|
|
|
{
|
|
|
|
|
//如果有 数据资源提供者 resourceProvider 就输出他的地址 以此类推
|
|
|
|
|
if(count($addrs['resourceProvider'])>0)
|
|
|
|
|
{
|
|
|
|
|
$addrs['addrs'][] = $addrs['resourceProvider'];
|
|
|
|
|
return $addrs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(count($addrs['owner'])>0)
|
|
|
|
|
{
|
|
|
|
|
$addrs['addrs'][] = $addrs['owner'];
|
|
|
|
|
return $addrs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(count($addrs['pointOfContact'])>0)
|
|
|
|
|
{
|
|
|
|
|
$addrs['addrs'][] = $addrs['pointOfContact'];
|
|
|
|
|
return $addrs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(count($addrs['author'])>0)
|
|
|
|
|
{
|
|
|
|
|
$addrs['addrs'][] = $addrs['author'];
|
|
|
|
|
return $addrs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(count($addrs["publisher"])>0)
|
|
|
|
|
{
|
|
|
|
|
$addrs['addrs'][] = $addrs["publisher"];
|
|
|
|
|
return $addrs;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}//getEmail 获取数据作者email地址
|
|
|
|
|
|
|
|
|
|
|
2012-03-07 03:48:40 +00:00
|
|
|
|
|
2012-03-06 08:06:54 +00:00
|
|
|
|
/*
|
|
|
|
|
* applyAction() 申请成为元数据作者
|
|
|
|
|
*
|
|
|
|
|
* param string $ac //动作 search|apply
|
|
|
|
|
* param string $q //搜索关键词
|
|
|
|
|
* param string $uuid //数据的UUID
|
|
|
|
|
*
|
|
|
|
|
* return view|ajax|json
|
|
|
|
|
*
|
|
|
|
|
* 调试搜索结果:
|
|
|
|
|
* /author/apply?ac=apply&uuid=816ecd28-ba88-464b-a83a-341440f536ef
|
|
|
|
|
*/
|
|
|
|
|
function applyAction()
|
|
|
|
|
{
|
|
|
|
|
$ac = $this->_request->getParam('ac');
|
|
|
|
|
|
|
|
|
|
//搜索动作
|
|
|
|
|
if($ac == "search")
|
|
|
|
|
{
|
|
|
|
|
$this->_helper->layout->disableLayout();
|
|
|
|
|
$this->_helper->viewRenderer->setNoRender();
|
|
|
|
|
|
|
|
|
|
//要输出的Json对象
|
|
|
|
|
//过程中如果没有处理,则不包含任何返回信息,由前台定义提示信息,如:
|
|
|
|
|
/*
|
|
|
|
|
$.ajax({
|
|
|
|
|
'type':"POST",
|
|
|
|
|
'url':'/author/apply',
|
|
|
|
|
'data':'ac=search&q='+$('#keyword').val(),
|
|
|
|
|
'success':function(data){
|
|
|
|
|
if (typeof(data)=='object') //如果服务器端的响应为Json对象
|
|
|
|
|
{
|
|
|
|
|
if(typeof(data.error)!='undefined') //服务器端响应的错误消息
|
|
|
|
|
{
|
|
|
|
|
alert(data.error);
|
|
|
|
|
}else{ //服务器端无错误消息则为成功的响应
|
|
|
|
|
alert(data.length);
|
|
|
|
|
}
|
|
|
|
|
}else{ //服务器端响应了非JSON对象或者为空
|
|
|
|
|
alert('无搜索结果');
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
'beforeSend':function(){
|
|
|
|
|
//请求发送前
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
错误消息的键名必须为error,不包含JS脚本,如:
|
|
|
|
|
$data['error'] = '服务器忙!';
|
|
|
|
|
*/
|
|
|
|
|
$data = "";
|
|
|
|
|
|
|
|
|
|
//防止通过其它方式访问,先判断是否是登录用户,如果不是,抛出消息后强制用户退出
|
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
|
if($auth->hasIdentity())
|
|
|
|
|
{
|
|
|
|
|
$user = $auth->getIdentity();
|
|
|
|
|
$u_id = $user->id;
|
|
|
|
|
}else{
|
|
|
|
|
$data = array("error"=>"请先登录");
|
|
|
|
|
$this ->getResponse()
|
|
|
|
|
->setHeader('Content-Type', 'application/json')
|
|
|
|
|
->appendBody(Zend_Json::encode($data));
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//数据处理代码 EOH<<<<<<<<<<<<<<<<
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$keyword = trim($this->_request->getParam('q'));
|
|
|
|
|
if (!preg_match_all("/^[\x{4e00}-\x{9fa5}A-Za-z0-9_]+$/u",$keyword,$matchs))
|
|
|
|
|
{
|
|
|
|
|
$data = array('error'=>'搜索关键字中只能包含汉字、英文、数字');
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//搜索标题和描述两个字段
|
2012-03-19 09:06:00 +00:00
|
|
|
|
$sql = "SELECT m.uuid,m.title,m.description,a.status,a.userid FROM normalmetadata m
|
2012-03-06 08:06:54 +00:00
|
|
|
|
LEFT JOIN mdauthor a ON m.uuid=a.uuid
|
|
|
|
|
WHERE m.title like ? OR m.description like ?";
|
|
|
|
|
$sth = $this->db->prepare($sql);
|
|
|
|
|
$sth->execute(array("%$keyword%","%$keyword%"));
|
|
|
|
|
$rows = $sth->fetchAll();
|
|
|
|
|
|
|
|
|
|
if(is_array($rows) && count($rows)>0)
|
|
|
|
|
$data = $rows;
|
|
|
|
|
else
|
|
|
|
|
$data = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
//如果上面的程序已经发送出提示,就不发送抛出的错误
|
|
|
|
|
if(empty($data['error']))
|
|
|
|
|
{
|
2012-03-12 08:44:20 +00:00
|
|
|
|
if($this->debug==0)
|
|
|
|
|
{
|
|
|
|
|
$data = array("error"=>"处理过程中遇到错误,请重新尝试");
|
|
|
|
|
}else{
|
|
|
|
|
$data = array("error"=>$e->getMessage());
|
|
|
|
|
}
|
2012-03-06 08:06:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// >>>>>>>>>>> F
|
|
|
|
|
|
|
|
|
|
//截获响应对象,并修改头部和内容
|
|
|
|
|
//不管有没有数据存在,都将返回Json数据,前台有判断机制来分析数据
|
|
|
|
|
|
|
|
|
|
$this ->getResponse()
|
|
|
|
|
->setHeader('Content-Type', 'application/json')
|
|
|
|
|
->appendBody(Zend_Json::encode($data));
|
|
|
|
|
}// search
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/****************
|
|
|
|
|
申请动作
|
|
|
|
|
****************/
|
|
|
|
|
if($ac == "apply")
|
|
|
|
|
{
|
|
|
|
|
$this->_helper->layout->disableLayout();
|
|
|
|
|
$this->_helper->viewRenderer->setNoRender();
|
|
|
|
|
|
|
|
|
|
$data = "";
|
|
|
|
|
|
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
|
if($auth->hasIdentity())
|
|
|
|
|
{
|
|
|
|
|
$user = $auth->getIdentity();
|
|
|
|
|
$u_id = $user->id;
|
|
|
|
|
$u_email = $user->email;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//处理部分<<<<<<<<<<
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$uuid = $this->_request->getParam('uuid');
|
2012-03-07 03:48:40 +00:00
|
|
|
|
$m = $this->_request->getParam('m');
|
2012-03-06 08:06:54 +00:00
|
|
|
|
|
|
|
|
|
if(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))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
//判断该用户是否已经申请过或者是否已经是该元数据作者
|
|
|
|
|
$sql="SELECT id,status FROM mdauthor WHERE uuid=? AND userid=?";
|
|
|
|
|
$sth = $this->db->prepare($sql);
|
|
|
|
|
$sth->execute(array($uuid,$u_id));
|
|
|
|
|
$row = $sth->fetch();
|
|
|
|
|
|
2012-03-07 03:48:40 +00:00
|
|
|
|
//如果已经是元数据作者,从流程中直接退出程序
|
|
|
|
|
if(!empty($row['id']) && $row['status']==1)
|
|
|
|
|
{
|
|
|
|
|
$data = array("error"=>"您目前已经是该数据作者,不需要再申请");
|
2012-03-06 08:06:54 +00:00
|
|
|
|
}
|
2012-03-20 09:34:44 +00:00
|
|
|
|
|
|
|
|
|
//如果已经遭到明确拒绝,则不允许用户再次申请
|
|
|
|
|
if(!empty($row['id']) && $row['status']==-1)
|
|
|
|
|
{
|
|
|
|
|
$data = array("error"=>"您的申请已经遭到拒绝,不能再申请,有疑问请联系数据中心");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-03-07 03:48:40 +00:00
|
|
|
|
//如果已经存在申请,但是没有激活的,返回激活信息
|
|
|
|
|
if($row['status']==0){
|
|
|
|
|
if(!empty($row['id']) && empty($m))
|
|
|
|
|
{
|
|
|
|
|
$data = array(
|
2012-03-20 09:34:44 +00:00
|
|
|
|
"error"=>'您已经申请过了,如果长时间没有收到回应请联系数据中心',
|
2012-03-07 03:48:40 +00:00
|
|
|
|
"post"=>"activa",
|
|
|
|
|
"uid"=>$u_id,
|
|
|
|
|
"uemail"=>$u_email,
|
|
|
|
|
"uuid"=>$uuid,
|
|
|
|
|
);
|
|
|
|
|
}//if
|
2012-03-06 08:06:54 +00:00
|
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
2012-03-20 09:34:44 +00:00
|
|
|
|
$info = $this->getEmail($uuid,1);
|
|
|
|
|
|
|
|
|
|
$address = $info['addrs'];
|
|
|
|
|
|
|
|
|
|
$mdtitle = $info['title'];
|
2012-03-06 08:06:54 +00:00
|
|
|
|
|
|
|
|
|
//如果当前用户的email包含在元数据作者email列表中,则直接使其成为元数据作者
|
|
|
|
|
if(in_array($u_email,$address))
|
|
|
|
|
{
|
|
|
|
|
$sql = "INSERT INTO mdauthor (uuid,userid,activation,ts_activated,status) VALUES (?,?,?,?,?)";
|
|
|
|
|
$sth = $this->db->prepare($sql);
|
|
|
|
|
$ex = $sth->execute(array($uuid,$u_id,'','now()',1));
|
|
|
|
|
if($ex)
|
|
|
|
|
{
|
|
|
|
|
$data = array("error"=>"您的身份符合申请条件,已经自动成为该元数据作者");
|
|
|
|
|
include_once("EmailText.php");
|
|
|
|
|
$mail=new WestdcMailer($this->view->config->smtp);
|
|
|
|
|
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
2012-03-21 02:56:50 +00:00
|
|
|
|
$mailtp=new EmailText($this->db,"author-new",array(
|
2012-03-06 08:06:54 +00:00
|
|
|
|
'user' => $user->realname,
|
|
|
|
|
'uuid' => $uuid,
|
|
|
|
|
'title'=> $mdtitle,
|
|
|
|
|
'email'=> $u_email,
|
|
|
|
|
));
|
|
|
|
|
$mail->setBodyText($mailtp->getBody());
|
|
|
|
|
$mail->setSubject($mailtp->getSubject());
|
2012-03-21 02:56:50 +00:00
|
|
|
|
|
2012-03-12 08:44:20 +00:00
|
|
|
|
if($this->debug==0)
|
|
|
|
|
{
|
|
|
|
|
foreach ($address as $dist)
|
|
|
|
|
{$mail->addTo($dist);} //元数据作者
|
|
|
|
|
$mail->addTo($u_email);
|
|
|
|
|
$mail->addCc($this->view->config->service->email); //管理员
|
|
|
|
|
}else{
|
|
|
|
|
$mail->addTo($this->debug_email);
|
|
|
|
|
}
|
2012-03-06 08:06:54 +00:00
|
|
|
|
$mail->send();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$data = array("error"=>"处理中出现错误,请重新尝试");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//如果不包含在当前元数据作者的email列表中
|
2012-03-20 09:34:44 +00:00
|
|
|
|
//给数据拥有者发送邮件,使其决定是否同意新加入作者
|
2012-03-06 08:06:54 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//生成激活码
|
|
|
|
|
$ssid = session_id();
|
|
|
|
|
$vdcode = md5($uuid.$ssid.$u_id.time());
|
|
|
|
|
|
|
|
|
|
//激活链接
|
|
|
|
|
// /author/accept/?ac=active&vdcode=$vdcode
|
2012-03-21 02:56:50 +00:00
|
|
|
|
if(empty($m))
|
2012-03-07 03:48:40 +00:00
|
|
|
|
{
|
|
|
|
|
$sql = "INSERT INTO mdauthor (uuid,userid,activation) VALUES (?,?,?)";
|
|
|
|
|
$sth = $this->db->prepare($sql);
|
|
|
|
|
$ex = $sth->execute(array($uuid,$u_id,$vdcode));
|
|
|
|
|
}else{
|
2012-03-12 08:56:46 +00:00
|
|
|
|
$sql = "UPDATE mdauthor SET activation=?,ts_created=? WHERE uuid=? AND userid=?";
|
2012-03-07 03:48:40 +00:00
|
|
|
|
$sth = $this->db->prepare($sql);
|
2012-03-12 08:56:46 +00:00
|
|
|
|
$ex = $sth->execute(array($vdcode,'now()',$uuid,$u_id));
|
2012-03-07 03:48:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-03-06 08:06:54 +00:00
|
|
|
|
if($ex)
|
|
|
|
|
{
|
2012-03-21 02:56:50 +00:00
|
|
|
|
//给申请者发送邮件
|
2012-03-06 08:06:54 +00:00
|
|
|
|
include_once("EmailText.php");
|
|
|
|
|
@$mail=new WestdcMailer($this->view->config->smtp);
|
|
|
|
|
@$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
2012-03-19 09:06:00 +00:00
|
|
|
|
@$mailtp=new EmailText($this->db,"author-apply",array(
|
2012-03-06 08:06:54 +00:00
|
|
|
|
'user' => $user->username,
|
2012-03-21 03:28:12 +00:00
|
|
|
|
'uuid' => $uuid,
|
|
|
|
|
'email'=> $user->email,
|
2012-03-20 09:34:44 +00:00
|
|
|
|
//元数据标题
|
2012-03-06 08:06:54 +00:00
|
|
|
|
'title'=> $mdtitle,
|
|
|
|
|
));
|
|
|
|
|
@$mail->setBodyText($mailtp->getBody());
|
|
|
|
|
@$mail->setSubject($mailtp->getSubject());
|
2012-03-12 08:44:20 +00:00
|
|
|
|
if($this->debug==0)
|
|
|
|
|
{
|
2012-03-20 09:34:44 +00:00
|
|
|
|
@$mail->addTo($user->email);
|
2012-03-12 08:44:20 +00:00
|
|
|
|
}else{
|
|
|
|
|
@$mail->addTo($this->debug_email);
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-06 08:06:54 +00:00
|
|
|
|
@$mail->send();
|
|
|
|
|
|
|
|
|
|
unset($mail);
|
|
|
|
|
unset($mailtp);
|
2012-03-21 02:56:50 +00:00
|
|
|
|
//给元数据作者以及管理员发送邮件
|
2012-03-06 08:06:54 +00:00
|
|
|
|
@$mail=new WestdcMailer($this->view->config->smtp);
|
|
|
|
|
@$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
2012-03-19 09:06:00 +00:00
|
|
|
|
@$mailtp=new EmailText($this->db,"author-apply-confirm",array(
|
2012-03-06 08:06:54 +00:00
|
|
|
|
'user' => $user->username,
|
|
|
|
|
'uuid' => $uuid,
|
|
|
|
|
'email'=> $u_email,
|
|
|
|
|
'title'=> $mdtitle,
|
|
|
|
|
'link'=>"http://".$_SERVER['SERVER_NAME']."/data/$uuid",
|
2012-03-20 09:34:44 +00:00
|
|
|
|
|
|
|
|
|
//验证码
|
|
|
|
|
'vdcode' => $vdcode,
|
|
|
|
|
|
|
|
|
|
//激活链接
|
|
|
|
|
'active'=>"http://".$_SERVER['SERVER_NAME']."/author/accept/?ac=active&v=$vdcode",
|
|
|
|
|
|
|
|
|
|
//不同意激活的链接
|
|
|
|
|
'lock'=>"http://".$_SERVER['SERVER_NAME']."/author/accept/?ac=lock&v=$vdcode",
|
2012-03-06 08:06:54 +00:00
|
|
|
|
));
|
|
|
|
|
@$mail->setBodyText($mailtp->getBody());
|
|
|
|
|
@$mail->setSubject($mailtp->getSubject());
|
2012-03-21 02:56:50 +00:00
|
|
|
|
|
2012-03-12 08:44:20 +00:00
|
|
|
|
if($this->debug==0)
|
2012-03-21 03:28:12 +00:00
|
|
|
|
{
|
|
|
|
|
$sql = "SELECT u.email FROM mdauthor a
|
|
|
|
|
LEFT JOIN users u ON u.id=a.userid
|
|
|
|
|
WHERE a.uuid=?";
|
|
|
|
|
$sth = $this->db->prepare($sql);
|
|
|
|
|
$sth->execute(array($uuid));
|
|
|
|
|
$mlist = $sth->fetchAll();
|
|
|
|
|
|
|
|
|
|
if(count($mlist)>0)
|
|
|
|
|
{
|
|
|
|
|
foreach($mlist as $v)
|
|
|
|
|
{
|
|
|
|
|
$mail->addTo($v['email']);
|
|
|
|
|
}
|
|
|
|
|
}//mdauthor中已经注册的用户
|
|
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
foreach ($address as $dist)
|
|
|
|
|
{
|
|
|
|
|
$mail->addTo($dist);
|
|
|
|
|
}
|
|
|
|
|
}//元数据作者
|
2012-03-21 02:56:50 +00:00
|
|
|
|
$mail->addCc($this->view->config->service->email); //管理员
|
2012-03-12 08:44:20 +00:00
|
|
|
|
}else{
|
|
|
|
|
@$mail->addTo($this->debug_email);
|
|
|
|
|
}
|
2012-03-20 09:34:44 +00:00
|
|
|
|
|
2012-03-06 08:06:54 +00:00
|
|
|
|
@$mail->send();
|
|
|
|
|
|
2012-03-20 09:34:44 +00:00
|
|
|
|
$data = array("error"=>"您的申请已收到,请耐心等待回应");
|
|
|
|
|
|
2012-03-06 08:06:54 +00:00
|
|
|
|
}else{
|
|
|
|
|
$data = array("error"=>"服务器可能在忙,请重试。");
|
|
|
|
|
}//激活码记录
|
|
|
|
|
}//不是确认的元数据作者
|
|
|
|
|
}//empty($row['id'])
|
2012-03-07 03:48:40 +00:00
|
|
|
|
}// status == 0
|
2012-03-06 08:06:54 +00:00
|
|
|
|
|
|
|
|
|
//调试输出结果
|
|
|
|
|
//$data = array('addr'=>$address,'uemail'=>$u_email);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$data = array('error'=>'参数出错,请按照正确的访问方式申请');
|
|
|
|
|
}
|
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
if(empty($data['error']))
|
|
|
|
|
{
|
2012-03-12 08:44:20 +00:00
|
|
|
|
if($this->debug==0)
|
|
|
|
|
{
|
|
|
|
|
$data = array("error"=>"处理过程中遇到错误,请重新尝试");
|
|
|
|
|
}else{
|
|
|
|
|
$data = array("error"=>$e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-06 08:06:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// >>>>>>>>>>>>
|
|
|
|
|
|
|
|
|
|
$this ->getResponse()
|
|
|
|
|
->setHeader('Content-Type', 'application/json')
|
|
|
|
|
->appendBody(Zend_Json::encode($data));
|
|
|
|
|
|
|
|
|
|
}// ac = apply 申请处理
|
|
|
|
|
|
|
|
|
|
}//applyAction() 申请成为元数据作者
|
2012-03-14 09:16:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* authoredAction() 数据反馈
|
|
|
|
|
*
|
2012-03-20 09:34:44 +00:00
|
|
|
|
* param string $ac 动作
|
2012-03-14 09:16:25 +00:00
|
|
|
|
* param string $uuid 元数据UUID
|
|
|
|
|
* param int $page 页数
|
|
|
|
|
*
|
2012-03-20 09:34:44 +00:00
|
|
|
|
* return view
|
2012-03-14 09:16:25 +00:00
|
|
|
|
*/
|
|
|
|
|
function authoredAction()
|
|
|
|
|
{
|
|
|
|
|
$ac = $this->_request->getParam('ac');
|
|
|
|
|
|
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
|
if($auth->hasIdentity())
|
|
|
|
|
{
|
|
|
|
|
$user = $auth->getIdentity();
|
|
|
|
|
$u_id = $user->id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(empty($ac)|| $ac=='list')
|
|
|
|
|
{
|
|
|
|
|
$sql = "SELECT md.title,md.uuid,count(c.id) as c FROM comments c
|
|
|
|
|
LEFT JOIN metadata md ON md.uuid=c.uuid
|
|
|
|
|
LEFT JOIN mdauthor a ON md.uuid=a.uuid
|
|
|
|
|
WHERE md.title IS NOT NULL AND a.userid=?
|
|
|
|
|
GROUP BY md.title,md.uuid
|
|
|
|
|
";
|
|
|
|
|
$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;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($ac=="view")
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
$uuid = $this->_request->getParam('uuid');
|
|
|
|
|
if(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))
|
|
|
|
|
{
|
|
|
|
|
$sql = "SELECT c.author,c.email,c.url,c.ts_created,c.content FROM comments c
|
|
|
|
|
LEFT JOIN mdauthor a ON a.uuid=c.uuid
|
|
|
|
|
WHERE c.uuid=? AND a.userid=?
|
|
|
|
|
ORDER BY ts_created DESC";
|
|
|
|
|
|
|
|
|
|
$sth = $this->db->prepare($sql);
|
|
|
|
|
$sth->execute(array($uuid,$u_id));
|
|
|
|
|
$rows = $sth->fetchAll();
|
|
|
|
|
|
|
|
|
|
$paginator = Zend_Paginator::factory($rows);
|
|
|
|
|
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
|
|
|
|
$paginator->setItemCountPerPage(10);
|
|
|
|
|
$paginator->setView($this->view);
|
|
|
|
|
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
|
|
|
|
$this->view->paginator=$paginator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->_helper->viewRenderer('authored-list');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($ac == "listall")
|
|
|
|
|
{
|
|
|
|
|
$sql = "SELECT md.title,c.author,c.email,c.url,c.ts_created,c.content FROM comments c
|
|
|
|
|
LEFT JOIN mdauthor a ON a.uuid=c.uuid
|
|
|
|
|
LEFT JOIN metadata md ON md.uuid=c.uuid
|
|
|
|
|
WHERE a.userid=?
|
|
|
|
|
ORDER BY ts_created 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(10);
|
|
|
|
|
$paginator->setView($this->view);
|
|
|
|
|
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
|
|
|
|
$this->view->paginator=$paginator;
|
|
|
|
|
|
|
|
|
|
$this->_helper->viewRenderer('authored-listall');
|
|
|
|
|
}
|
|
|
|
|
}// authoredAction() 数据反馈
|
2012-03-20 09:34:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* newsAction() 数据新闻
|
|
|
|
|
*
|
|
|
|
|
* param string $ac
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
function newsAction(){
|
|
|
|
|
|
|
|
|
|
$ac = $this->_request->getParam('ac');
|
|
|
|
|
|
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
|
if($auth->hasIdentity())
|
|
|
|
|
{
|
|
|
|
|
$user = $auth->getIdentity();
|
|
|
|
|
$u_id = $user->id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//新闻发布
|
|
|
|
|
if($ac == "add")
|
|
|
|
|
{
|
|
|
|
|
$this->_helper->viewRenderer('news-add');
|
|
|
|
|
}// $ac == add
|
|
|
|
|
|
|
|
|
|
//新闻发布的ajax动作
|
|
|
|
|
if($ac =="addnews")
|
|
|
|
|
{
|
|
|
|
|
$this->_helper->layout->disableLayout();
|
|
|
|
|
$this->_helper->viewRenderer->setNoRender();
|
|
|
|
|
|
|
|
|
|
$data = array();
|
|
|
|
|
|
|
|
|
|
$data['title'] = $this->_request->getParam('title');
|
|
|
|
|
$data['keyword'] = $this->_request->getParam('keyword');
|
|
|
|
|
$data['body'] = $this->_request->getParam('body');
|
|
|
|
|
|
|
|
|
|
foreach($data as $k=>$v)
|
|
|
|
|
{
|
|
|
|
|
$data[$k]=preg_replace("#<a([^>]*)>(.*)</a>#i","",$v);
|
|
|
|
|
$data[$k]=preg_replace("#<script([^>]*)>(.*)</script>#i","",$v);
|
|
|
|
|
$data[$k]=preg_replace("#<iframe([^>]*)>(.*)</iframe>#i","",$v);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$msg = array();
|
|
|
|
|
|
|
|
|
|
if(mb_strlen($data['title'],"utf-8")<=6)
|
|
|
|
|
{
|
|
|
|
|
$msg['status'] == 0;
|
|
|
|
|
$msg['error'] == '标题太短,请重新填写';
|
|
|
|
|
$this ->getResponse()
|
|
|
|
|
->setHeader('Content-Type', 'application/json')
|
|
|
|
|
->appendBody(Zend_Json::encode($msg));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}//newsAction() 数据新闻
|
2012-03-09 09:03:50 +00:00
|
|
|
|
|
2012-03-06 08:06:54 +00:00
|
|
|
|
|
2012-02-22 12:21:22 +00:00
|
|
|
|
}
|
|
|
|
|
|