#348 添加了数据作者对用户的邮件消息发送功能

This commit is contained in:
Li Jianxuan 2012-09-06 02:12:17 +00:00
parent 314664fb97
commit 15e2cfb8f2
3 changed files with 194 additions and 3 deletions

View File

@ -2943,6 +2943,92 @@ class AuthorController extends Zend_Controller_Action
}//委托 }//委托
/*
* sendmailAction() 邮件通知
*
* Param uuid $uuid //元数据UUID
*
* return Ajax-response
*
* 传入元数据UUID判断是否为当前用户的数据如果是即可向已经下载过该数据的所有用户发送电子邮件
*/
public function sendmailAction()
{
$uuid = $this->_getParam('uuid');
$ac = $this->_getParam('ac');
$auth = Zend_Auth::getInstance();
if($auth->hasIdentity())
{
$user = $auth->getIdentity();
$uid = $user->id;
}
if(empty($uuid) || empty($uid))
{
$this->view->error = "参数错误";
return true;
}
$sql = "SELECT a.*,m.title,m.description,g.id as gid,mds.status as mdstatus,m.uuid FROM normalmetadata m
LEFT JOIN mdauthor a ON m.uuid=a.uuid
LEFT JOIN geonetworkmetadata g on m.uuid=g.uuid
LEFT JOIN mdstatus mds ON m.uuid=mds.uuid
WHERE a.userid=? AND a.status>=0 AND m.uuid=?";
$sth = $this->db->prepare($sql);
$sth->execute(array($uid,$uuid));
$metadata = $sth->fetch();
if(empty($metadata['uuid']))
{
$this->view->error = "数据不存在或者您可能没有该数据的管理权限";
return true;
}
$this->view->metadata = $metadata;
$sql = "select u.email
from dataorder d
LEFT JOIN users u on d.userid = u.id
WHERE u.email IS NOT NULL
AND d.uuid=?
GROUP BY u.email";
$sth = $this->db->prepare($sql);
$sth->execute(array($uuid));
$mails = $sth->fetchAll();
$this->view->mailinfo = count($mails);
if($ac == "send")
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$title = $this->_getParam('title');
$body = $this->_getParam('body');
foreach($mails as $k=>$v)
{
$mail=new WestdcMailer($this->view->config->smtp);
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
$mail->setBodyText($body);
$mail->setSubject($title);
if($this->debug==0)
{
$mail->addTo($v['email']);
}else{
$mail->addTo($debug_email);
}
if($mail->send())
{
echo $v['email']."...发送成功!<br />";
}else{
echo $v['email']."...发送失败!<br />";
}
}
}
}
/* /*
* staticsAction() 数据统计 * staticsAction() 数据统计

View File

@ -49,8 +49,10 @@ $this->breadcrumb()->setSeparator(' > ');
| <a href="/author/delegate/uuid/<?php echo $item['uuid'];?>" onclick="return confirm('是否确定将该数据委托至数据中心?');">委托</a> | <a href="/author/delegate/uuid/<?php echo $item['uuid'];?>" onclick="return confirm('是否确定将该数据委托至数据中心?');">委托</a>
<?php } if($item['mdstatus']==7){ ?> <?php } if($item['mdstatus']==7){ ?>
| <a href="/author/delegate/ac/cancel/uuid/<?php echo $item['uuid'];?>" onclick="return confirm('是否确定取消该数据的委托?');">取消委托</a> | <a href="/author/delegate/ac/cancel/uuid/<?php echo $item['uuid'];?>" onclick="return confirm('是否确定取消该数据的委托?');">取消委托</a>
<?php }?> <?php }?> |
</span> <a href="/author/sendmail/uuid/<?php echo $item['uuid']; ?>">邮件通知</a>
</span>
<?php endif; ?> <?php endif; ?>
<p><?php echo mb_strlen($item['description'])>400?$this->escape(mb_substr($item['description'],0,400,'UTF-8').'...'):$this->escape($item['description']); ?></p> <p><?php echo mb_strlen($item['description'])>400?$this->escape(mb_substr($item['description'],0,400,'UTF-8').'...'):$this->escape($item['description']); ?></p>

View File

@ -0,0 +1,103 @@
<?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->headScript()->appendFile('/js/jquery.colorbox-min.js');
$this->headLink()->appendStylesheet('/css/colorbox.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/author">数据作者</a>');
$this->breadcrumb('<a href="/author/accept">我的数据</a>');
$this->breadcrumb('邮件通知');
$this->breadcrumb()->setSeparator(' > ');
?>
<!-- 左侧导航 -->
<div id='sidebar'>
<div id='leftnavi'>
<?= $this->partial('author/navi.phtml'); ?>
</div>
</div>
<!-- //左侧导航 -->
<!-- 页面内容 -->
<div id="wapper">
<?php
if(!empty($this->error))
{
echo $this->error;
}
?>
<?php
if(!empty($this->metadata))
{
?>
<h2><?= $this->metadata['title'] ?></h2>
<?php
}
if(!empty($this->mailinfo))
{
?>
共统计到可发送的电子邮件地址:<?= $this->mailinfo?>
<form id="mailform">
<p>
<label>邮件标题</label><br />
<input type="text" id="title" name="title" class="half" />
</p>
<p>
<label>邮件内容</label><br />
<textarea name="body" id="body" class="half large"></textarea>
</p>
<p>
<input type="hidden" name="uuid" value="<?= $this->metadata['uuid']?>" />
<button type="button" class="btn btn-green" id="send_btn" onclick="sendmail()">发送邮件</button>
</p>
<p>
<iframe id="process" style="border:none;width:500px;height:300px;font-size:12px;" src=""></iframe>
</p>
</form>
<?php
}
?>
</div>
<!-- //页面内容 -->
<script>
$('#wapper').width($('body').width()-300);
function sendmail(){
if($('#process').attr("src") != "")
{
Alert("您已经发送过邮件,如果页面没有反应请继续等待服务器响应");return false;
}
if($("#title").val() == "")
{
Alert("请填写邮件标题");return false;
}
if($("#body").val() == "")
{
Alert("请填写邮件内容");return false;
}
if($("#body").val().length <= 20 )
{
Alert("邮件内容过短,请重新填写");return false;
}
if(confirm("是否确定发送邮件")==false)
{
return false;
}
$('#process').attr("src","/author/sendmail/?ac=send&"+$('#mailform').serialize());
}
$('#send_btn').ajaxComplete(function() {
$('#send_btn').html('发送邮件');
});
$('#send_btn').ajaxSend(function() {
$('#send_btn').html('<img src="/images/ajax-load-small.gif" />正在处理...');
});
$("#send_btn").ajaxError(function() {
$('#send_btn').html('发送邮件');
Alert('处理中出现问题,请重试');
});
function Alert(html){
$.colorbox({'innerWidth':'50%','html':'<h4>'+html+'</h4>'});
}
function isObject(obj){if(typeof(obj)=='object'){return true;}else if(typeof(obj)!='object'){return false;}else{return false;}}
</script>