#399 后台添加发送邮件通知功能
This commit is contained in:
parent
d4f7c09969
commit
8c371c4c71
|
@ -920,6 +920,89 @@ class Admin_DownController extends Zend_Controller_Action
|
|||
}//查看单个数据下载情况
|
||||
|
||||
}//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()
|
||||
{
|
||||
|
|
|
@ -46,8 +46,8 @@
|
|||
<li><p><a href="/data/<?= $item['uuid']; ?>" class="title"><?= $item['title']; ?></a></p>
|
||||
<p>大小:<?= $item['filesize']; ?>M,创建时间:<?= date('Y-m-d',strtotime($item['ts_created'])); ?>
|
||||
,查看:<?= $item['viewed']; ?>次。 操作:
|
||||
<a href="/service/geonetwork?url=metadata.edit?id=<?= $item['gid']; ?>" target="_blank">编辑</a> |
|
||||
<a href="/admin/data/md/delete/<?= $item['id']; ?>">删除</a> |
|
||||
<a href="/service/geonetwork?url=metadata.edit?id=<?= $item['gid']; ?>" target="_blank">编辑</a> |
|
||||
<a href="/admin/data/md/delete/<?= $item['id']; ?>">删除</a> |
|
||||
<a href="/admin/data/sync/uuid/<?= $item['uuid']; ?>">同步</a> |
|
||||
<a href="/admin/data/reference/show/<?php echo $item['uuid'];?>">文献管理</a> |
|
||||
<a href="/admin/data/md/att/1/uuid/<?php echo $item['uuid'];?>">附件管理</a> |
|
||||
|
@ -59,10 +59,11 @@
|
|||
<?php endif; ?>
|
||||
<a href="/admin/data/source/do/datasource/uuid/<?php echo $item['uuid'];?>">编辑数据来源</a> |
|
||||
<?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: ?>
|
||||
<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;?>
|
||||
<a href="/admin/down/sendmail/uuid/<?php echo $item['uuid'];?>" title="向数据下载者发送通知邮件">邮件通知</a>
|
||||
</p>
|
||||
<?php if($item['author']) :?>
|
||||
<p>数据贡献者:<?= $item['author']; ?></p>
|
||||
|
|
|
@ -1,61 +1,62 @@
|
|||
<?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/down">申请管理</a>');
|
||||
$this->breadcrumb('在线下载记录');
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
$this->headScript()->appendFile('/js/prototype.js');
|
||||
?>
|
||||
|
||||
<div id="leftPanel">
|
||||
<?= $this->partial('down/left.phtml'); ?>
|
||||
</div>
|
||||
<div id="rightPanel">
|
||||
<?php if ($this->msg or $this->messages) :?>
|
||||
<div id="message">
|
||||
<?php if ($this->msg) : ?>
|
||||
<p><?php echo $this->msg; ?></p>
|
||||
<?php endif; if ($this->messages): foreach($this->messages as $msg): ?>
|
||||
<p><?php echo $msg; ?></p>
|
||||
<?php endforeach;endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="right_title"><?php if(!empty($this->title)) echo $this->title;?>共 <?php echo $this->count;?> 数据下载记录</div>
|
||||
|
||||
<div class="search">
|
||||
<form action="/admin/down/data/" method="get">
|
||||
<input type="hidden" name="search" value='1' />
|
||||
<ul>
|
||||
<li><label>搜索关键字</label><input type="text" name="keyword" value="<?php echo $this->keyword; ?>" /></li>
|
||||
<li><input type="submit" class="searchbtn" value="搜索" /></li>
|
||||
</ul>
|
||||
</form>
|
||||
</div><!-- search DIV -->
|
||||
|
||||
<table><thead>
|
||||
<tr>
|
||||
<td width='350'>数据</td>
|
||||
<td width='150'>下载次数</td>
|
||||
<td width='150'>操作</td>
|
||||
</tr></thead>
|
||||
<?php if (count($this->paginator)): ?>
|
||||
<?php $autoindex=0;?>
|
||||
<?php foreach ($this->paginator as $item): ?>
|
||||
<?php $autoindex++;?>
|
||||
<tr class="<?php if($autoindex%2 == 0) echo 'even'; else echo 'odd'; ?>">
|
||||
<td><a href="/data/<?php echo $item['uuid'];?>" target="_blank"><img src="/images/data.gif" /></a><a href="/admin/down/data/show/<?php echo $item['uuid'];?>"><?php echo $item['title'];?></a></td>
|
||||
<td><?php echo $item['num']; ?></td>
|
||||
<td>
|
||||
<a href='/admin/down/data/show/<?php echo $item['uuid'];?>'>详细</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
<div class="pagenavi"><?= $this->paginator; ?></div>
|
||||
<?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/down">申请管理</a>');
|
||||
$this->breadcrumb('在线下载记录');
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
$this->headScript()->appendFile('/js/prototype.js');
|
||||
?>
|
||||
|
||||
<div id="leftPanel">
|
||||
<?= $this->partial('down/left.phtml'); ?>
|
||||
</div>
|
||||
<div id="rightPanel">
|
||||
<?php if ($this->msg or $this->messages) :?>
|
||||
<div id="message">
|
||||
<?php if ($this->msg) : ?>
|
||||
<p><?php echo $this->msg; ?></p>
|
||||
<?php endif; if ($this->messages): foreach($this->messages as $msg): ?>
|
||||
<p><?php echo $msg; ?></p>
|
||||
<?php endforeach;endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="right_title"><?php if(!empty($this->title)) echo $this->title;?>共 <?php echo $this->count;?> 数据下载记录</div>
|
||||
|
||||
<div class="search">
|
||||
<form action="/admin/down/data/" method="get">
|
||||
<input type="hidden" name="search" value='1' />
|
||||
<ul>
|
||||
<li><label>搜索关键字</label><input type="text" name="keyword" value="<?php echo $this->keyword; ?>" /></li>
|
||||
<li><input type="submit" class="searchbtn" value="搜索" /></li>
|
||||
</ul>
|
||||
</form>
|
||||
</div><!-- search DIV -->
|
||||
|
||||
<table><thead>
|
||||
<tr>
|
||||
<td width='350'>数据</td>
|
||||
<td width='150'>下载次数</td>
|
||||
<td width='150'>操作</td>
|
||||
</tr></thead>
|
||||
<?php if (count($this->paginator)): ?>
|
||||
<?php $autoindex=0;?>
|
||||
<?php foreach ($this->paginator as $item): ?>
|
||||
<?php $autoindex++;?>
|
||||
<tr class="<?php if($autoindex%2 == 0) echo 'even'; else echo 'odd'; ?>">
|
||||
<td><a href="/data/<?php echo $item['uuid'];?>" target="_blank"><img src="/images/data.gif" /></a><a href="/admin/down/data/show/<?php echo $item['uuid'];?>"><?php echo $item['title'];?></a></td>
|
||||
<td><?php echo $item['num']; ?></td>
|
||||
<td>
|
||||
<a href='/admin/down/data/show/<?php echo $item['uuid'];?>'>详细</a>
|
||||
<a href="/admin/down/sendmail/uuid/<?php echo $item['uuid'];?>" title="向数据下载者发送通知邮件">邮件通知</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
<div class="pagenavi"><?= $this->paginator; ?></div>
|
||||
</div>
|
|
@ -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