#399 后台添加发送邮件通知功能
This commit is contained in:
parent
d4f7c09969
commit
8c371c4c71
|
@ -921,6 +921,89 @@ class Admin_DownController extends Zend_Controller_Action
|
||||||
|
|
||||||
}//dataAction 数据下载情况
|
}//dataAction 数据下载情况
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 m.title,m.description,g.id as gid,mds.status as mdstatus,m.uuid FROM normalmetadata m
|
||||||
|
LEFT JOIN geonetworkmetadata g on m.uuid=g.uuid
|
||||||
|
LEFT JOIN mdstatus mds ON m.uuid=mds.uuid
|
||||||
|
WHERE m.uuid=?";
|
||||||
|
$sth = $this->db->prepare($sql);
|
||||||
|
$sth->execute(array($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);
|
||||||
|
$mail->addTo($v['email']);
|
||||||
|
//$mail->addTo("Jack@sookon.com");
|
||||||
|
if($mail->send())
|
||||||
|
{
|
||||||
|
echo $v['email']."...发送成功!<br />";
|
||||||
|
}else{
|
||||||
|
echo $v['email']."...发送失败!<br />";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}//sendmailAction() 为下载过某数据的用户发送邮件
|
||||||
|
|
||||||
function searchAction()
|
function searchAction()
|
||||||
{
|
{
|
||||||
$search = $this->_getParam('search');
|
$search = $this->_getParam('search');
|
||||||
|
|
|
@ -59,10 +59,11 @@
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<a href="/admin/data/source/do/datasource/uuid/<?php echo $item['uuid'];?>">编辑数据来源</a> |
|
<a href="/admin/data/source/do/datasource/uuid/<?php echo $item['uuid'];?>">编辑数据来源</a> |
|
||||||
<?php if(!empty($item['datasetid'])):?>
|
<?php if(!empty($item['datasetid'])):?>
|
||||||
<a href="/admin/data/dataset/ac/getdataset/uuid/<?php echo $item['uuid'];?>" class="iframe">存档</a>
|
<a href="/admin/data/dataset/ac/getdataset/uuid/<?php echo $item['uuid'];?>" class="iframe">存档</a> |
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<a href="/admin/data/dataset/ac/getdataset/uuid/<?php echo $item['uuid'];?>" class="iframe">添加存档</a>
|
<a href="/admin/data/dataset/ac/getdataset/uuid/<?php echo $item['uuid'];?>" class="iframe">添加存档</a> |
|
||||||
<?php endif;?>
|
<?php endif;?>
|
||||||
|
<a href="/admin/down/sendmail/uuid/<?php echo $item['uuid'];?>" title="向数据下载者发送通知邮件">邮件通知</a>
|
||||||
</p>
|
</p>
|
||||||
<?php if($item['author']) :?>
|
<?php if($item['author']) :?>
|
||||||
<p>数据贡献者:<?= $item['author']; ?></p>
|
<p>数据贡献者:<?= $item['author']; ?></p>
|
||||||
|
|
|
@ -52,6 +52,7 @@
|
||||||
<td><?php echo $item['num']; ?></td>
|
<td><?php echo $item['num']; ?></td>
|
||||||
<td>
|
<td>
|
||||||
<a href='/admin/down/data/show/<?php echo $item['uuid'];?>'>详细</a>
|
<a href='/admin/down/data/show/<?php echo $item['uuid'];?>'>详细</a>
|
||||||
|
<a href="/admin/down/sendmail/uuid/<?php echo $item['uuid'];?>" title="向数据下载者发送通知邮件">邮件通知</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
<?php
|
||||||
|
$this->headTitle($this->config->title->site);
|
||||||
|
$this->headTitle('后台管理');
|
||||||
|
$this->headTitle()->setSeparator(' - ');
|
||||||
|
$this->headLink()->appendStylesheet('/css/admin.css');
|
||||||
|
$this->breadcrumb('<a href="/">首页</a>');
|
||||||
|
$this->breadcrumb('<a href="/admin">后台首页</a>');
|
||||||
|
$this->breadcrumb('<a href="/admin/data">数据管理</a>');
|
||||||
|
$this->breadcrumb('元数据管理</a>');
|
||||||
|
$this->breadcrumb()->setSeparator(' > ');
|
||||||
|
$this->headScript()->appendFile('/js/jquery-1.7.min.js');
|
||||||
|
$this->headScript()->appendFile('/js/jquery.colorbox-min.js');
|
||||||
|
$this->headLink()->appendStylesheet('/css/colorbox.css');
|
||||||
|
?>
|
||||||
|
<div id="leftPanel">
|
||||||
|
<?= $this->partial('data/left.phtml'); ?>
|
||||||
|
</div>
|
||||||
|
<div id="rightPanel">
|
||||||
|
<?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","/admin/down/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>
|
Loading…
Reference in New Issue