Ticket #303 增加了数据作者邮件确认功能,增加了调试模式处理逻辑,增加了邮件激活所使用的视图
This commit is contained in:
parent
d98b7a7b55
commit
c7e7ae16f9
|
@ -9,11 +9,23 @@
|
|||
|
||||
@update 2012-3-1 15:06 李建轩
|
||||
@update 2012-3-9 17:01 李建轩
|
||||
@update 2012-3-12 16:16 李建轩
|
||||
|
||||
*/
|
||||
class AuthorController extends Zend_Controller_Action
|
||||
{
|
||||
private $limit=10;
|
||||
|
||||
//调试模式
|
||||
// 调试模式中将显示全部错误细节,电子邮件将发往调试邮箱
|
||||
// 1 为开启
|
||||
// 0 为关闭
|
||||
public $debug = 1;
|
||||
|
||||
//调试模式邮箱地址
|
||||
public $debug_email = "la5c@qq.com";
|
||||
|
||||
|
||||
function preDispatch()
|
||||
{
|
||||
$this->view->config = Zend_Registry::get('config');
|
||||
|
@ -62,7 +74,7 @@ class AuthorController extends Zend_Controller_Action
|
|||
$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
|
||||
WHERE (o.id in (SELECT distinct(onlineappid) from dataorder)) AND a.userid = ?
|
||||
WHERE (o.id in (SELECT distinct(onlineappid) from dataorder)) AND a.userid = ? AND a.status=1
|
||||
ORDER BY o.id desc";
|
||||
|
||||
$sth = $this->db->prepare($sql);
|
||||
|
@ -89,7 +101,7 @@ class AuthorController extends Zend_Controller_Action
|
|||
$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
|
||||
WHERE (o.id in (SELECT distinct(onlineappid) from dataorder)) AND a.userid = ? AND (m.title like ? or m.description like ?)
|
||||
WHERE (o.id in (SELECT distinct(onlineappid) from dataorder)) AND a.userid = ? AND (m.title like ? or m.description like ?) AND a.status=1
|
||||
ORDER BY o.id desc";
|
||||
|
||||
$sth = $this->db->prepare($sql);
|
||||
|
@ -128,7 +140,7 @@ class AuthorController extends Zend_Controller_Action
|
|||
left join dataorder d on o.id=d.offlineappid
|
||||
left join metadata md on md.uuid=d.uuid
|
||||
left join mdauthor a on a.uuid=d.uuid
|
||||
where o.ts_approved is null and o.pdflink is not null and d.uuid=? and a.userid=? and d.offlineappid=?
|
||||
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
|
||||
order by o.ts_created desc";
|
||||
|
||||
$sth = $this->db->prepare($sql);
|
||||
|
@ -186,7 +198,7 @@ class AuthorController extends Zend_Controller_Action
|
|||
left join dataorder d on o.id=d.offlineappid
|
||||
left join metadata md on md.uuid=d.uuid
|
||||
left join mdauthor a on a.uuid=d.uuid
|
||||
where o.ts_approved is null and o.pdflink is not null and d.status=4 and a.userid=?
|
||||
where o.ts_approved is null and o.pdflink is not null and d.status=4 and a.userid=? AND a.status=1
|
||||
order by o.ts_created desc";
|
||||
|
||||
$sth = $this->db->prepare($select);
|
||||
|
@ -227,7 +239,7 @@ class AuthorController extends Zend_Controller_Action
|
|||
left join dataorder d on o.id=d.offlineappid
|
||||
left join metadata md on md.uuid=d.uuid
|
||||
left join mdauthor a on a.uuid=d.uuid
|
||||
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=?
|
||||
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
|
||||
order by o.ts_created desc";
|
||||
|
||||
$sth = $this->db->prepare($select);
|
||||
|
@ -364,6 +376,91 @@ class AuthorController extends Zend_Controller_Action
|
|||
$this->view->paginator=$paginator;
|
||||
}
|
||||
}// search
|
||||
|
||||
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
|
||||
WHERE a.activation=? and a.userid=?";
|
||||
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute(array($vdcode,$u_id));
|
||||
$row = $sth->fetch();
|
||||
|
||||
if(empty($row['id']) || time() - strtotime($row['ts_created'])>3600* 72)
|
||||
{
|
||||
$this->view->info='此激活码无效,或者已经过期,请重新申请<br /><a href="/author/accept">点击这里</a>进入我的数据页面查看';
|
||||
}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,"md-author-newmember",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)
|
||||
{
|
||||
//获得元数据作者email
|
||||
$sql="select p.email,md.title from role r
|
||||
left join responsible p on r.resid=p.id
|
||||
left join metadata md on md.uuid=r.uuid
|
||||
where r.uuid=? order by r.role,r.id";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute(array($uuid));
|
||||
$rows = $sth->fetchAll();
|
||||
|
||||
$address = array();
|
||||
foreach($rows as $v)
|
||||
{
|
||||
$mail->addTo($v['email']);
|
||||
}
|
||||
$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
|
||||
{
|
||||
$this->view->info='此激活码已经失效,请重新申请<br /><a href="/author/accept">点击这里</a>进入我的数据页面查看';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}catch(Exception $e){
|
||||
if($this->debug==0)
|
||||
{
|
||||
$this->view->info = "处理中遇到错误,请重新尝试";
|
||||
}else{
|
||||
$this->view->info = $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}//acceptAction() 我的数据
|
||||
|
||||
|
@ -464,10 +561,12 @@ class AuthorController extends Zend_Controller_Action
|
|||
//如果上面的程序已经发送出提示,就不发送抛出的错误
|
||||
if(empty($data['error']))
|
||||
{
|
||||
//产品模式
|
||||
$data = array("error"=>"处理过程中遇到错误,请重新尝试");
|
||||
//调试模式
|
||||
//$data = array("error"=>$e->getMessage());
|
||||
if($this->debug==0)
|
||||
{
|
||||
$data = array("error"=>"处理过程中遇到错误,请重新尝试");
|
||||
}else{
|
||||
$data = array("error"=>$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
// >>>>>>>>>>> F
|
||||
|
@ -579,13 +678,15 @@ body=>
|
|||
{user} ({email}) 已经申请成为元数据《{title}》的作者,如果有疑问请联系该作者或者数据中心服务组
|
||||
中国西部环境与生态科学数据中心
|
||||
*/
|
||||
/*
|
||||
foreach ($address as $dist)
|
||||
{$mail->addTo($dist);} //元数据作者
|
||||
$mail->addTo($u_email);
|
||||
$mail->addCc($this->view->config->service->email); //管理员
|
||||
*/
|
||||
$mail->addTo("la5c@qq.com");
|
||||
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);
|
||||
}
|
||||
$mail->send();
|
||||
}
|
||||
else
|
||||
|
@ -642,9 +743,13 @@ body=>
|
|||
|
||||
中国西部环境与生态科学数据中心
|
||||
*/
|
||||
|
||||
//@$mail->addTo($u_email);
|
||||
@$mail->addTo("la5c@qq.com"); //Test line...
|
||||
if($this->debug==0)
|
||||
{
|
||||
@$mail->addTo($u_email);
|
||||
}else{
|
||||
@$mail->addTo($this->debug_email);
|
||||
}
|
||||
|
||||
@$mail->send();
|
||||
|
||||
unset($mail);
|
||||
|
@ -670,13 +775,14 @@ body=>
|
|||
元数据访问地址:{link}
|
||||
中国西部环境与生态科学数据中心
|
||||
*/
|
||||
|
||||
/*
|
||||
foreach ($address as $dist)
|
||||
{$mail->addTo($dist);} //元数据作者
|
||||
$mail->addCc($this->view->config->service->email); //管理员
|
||||
*/
|
||||
@$mail->addTo("la5c@qq.com");
|
||||
if($this->debug==0)
|
||||
{
|
||||
foreach ($address as $dist)
|
||||
{$mail->addTo($dist);} //元数据作者
|
||||
$mail->addCc($this->view->config->service->email); //管理员
|
||||
}else{
|
||||
@$mail->addTo($this->debug_email);
|
||||
}
|
||||
@$mail->send();
|
||||
|
||||
$data = array("error"=>"我们给您的邮箱中发送了激活链接,请按邮件提示进行激活操作。");
|
||||
|
@ -697,10 +803,13 @@ body=>
|
|||
}catch(Exception $e){
|
||||
if(empty($data['error']))
|
||||
{
|
||||
//产品模式
|
||||
//$data = array("error"=>"处理过程中遇到错误,请重新尝试");
|
||||
//调试模式
|
||||
$data = array("error"=>$e->getMessage());
|
||||
if($this->debug==0)
|
||||
{
|
||||
$data = array("error"=>"处理过程中遇到错误,请重新尝试");
|
||||
}else{
|
||||
$data = array("error"=>$e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
$this->headTitle($this->config->title->site);
|
||||
$this->headTitle($this->config->title->author);
|
||||
$this->headTitle()->setSeparator(' - ');
|
||||
$this->headScript()->appendFile('/js/jquery-1.7.min.js');
|
||||
$this->headLink()->appendStylesheet('/css/author.css');
|
||||
$this->breadcrumb('<a href="/">首页</a>');
|
||||
$this->breadcrumb('<a href="/author">数据作者</a>');
|
||||
$this->breadcrumb('我的数据');
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
?>
|
||||
<!-- 左侧导航 -->
|
||||
<div id='sidebar'>
|
||||
<div id='leftnavi'>
|
||||
<?= $this->partial('author/navi.phtml'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<!-- //左侧导航 -->
|
||||
|
||||
<!-- 页面内容 -->
|
||||
<div id="wapper">
|
||||
<?php echo $this->info; ?>
|
||||
</div>
|
||||
<!-- //页面内容 -->
|
||||
<script>
|
||||
$('#wapper').width($('body').width()-300);
|
||||
</script>
|
Loading…
Reference in New Issue