#438 添加了为黑河用户发送邮件通知的功能

This commit is contained in:
Li Jianxuan 2012-12-11 04:57:07 +00:00
parent 4e1ea47a8d
commit f60b21375e
4 changed files with 248 additions and 2 deletions

View File

@ -523,6 +523,8 @@ class Admin_UserController extends Zend_Controller_Action
$this->view->paginator=$paginator; $this->view->paginator=$paginator;
$this->view->count_users = count($rows); $this->view->count_users = count($rows);
return true;
} }
if($ac == "send") if($ac == "send")
@ -607,6 +609,122 @@ class Admin_UserController extends Zend_Controller_Action
'email'=>$v['email'], 'email'=>$v['email'],
'lastlogin'=>date("Y-m-d",strtotime($v['ts_last_login'])) 'lastlogin'=>date("Y-m-d",strtotime($v['ts_last_login']))
); );
//@$mail->send();
}
$this->view->result = $result;
$this->view->now = $start;
$this->view->total = $total;
$percent = round( ( $start / $total ) * 100 ,1);
$this->view->percent = $percent;
$page ++;
$this->view->page = $page;
return true;
}
if($ac == "heihe")
{
$this->_helper->viewRenderer('sendmail-heihe');
$sql = "SELECT * FROM heiheuser ORDER BY id DESC";
$sth = $this->db->query($sql);
$rows = $sth->fetchAll();
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(20);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
$this->view->count_users = count($rows);
return true;
}
if($ac == "heihemail")
{
$this->_helper->viewRenderer('sendmail-heihe-send');
//当前进行到的数量
$now = $this->_getParam('now');
//当前处理的页数
$page = $this->_getParam('page');
if(empty($page))
{
$page = 0;
}
$step = 20;
$sql = "SELECT count(id) as c FROM heiheuser";
$sth = $this->db->query($sql);
$row = $sth->fetch();
$total = $row['c'];
if(empty($now))
{
$now = 0;
}
//此次读取的起点
$start = $now + $step;
if($start>$total)
{
$this->view->stop = "YES";
$msg = array(
"title"=>"为数字黑河用户发送了邮件通知",
"body"=>"".time()." 时间给数字黑河用户发送了邮件通知 "
);
include_once("message.php");
message::post($this->db,0,-1,$msg['title'],$msg['body']);
return true;
}
$sql = "SELECT * FROM heiheuser
ORDER BY id DESC
LIMIT $step
OFFSET $start";
$sth = $this->db->query($sql);
$rows = $sth->fetchAll();
$result = array();
foreach($rows as $k=>$v)
{
include_once("EmailText.php");
$mail=new WestdcMailer($this->view->config->smtp);
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
$mailtp=new EmailText($this->db,"user-heihe-invite",array(
'user' => $v['username'],
'uid' => $v['id'],
'lastlogin'=> date("Y-m-d",strtotime($v['lastlogin'])),
));
$mail->setBodyText($mailtp->getBody());
$mail->setSubject($mailtp->getSubject());
@$mail->addTo($v['email']);
$result[$v['id']] = array(
'username'=>$v['username'],
'email'=>$v['email'],
'lastlogin'=>date("Y-m-d",strtotime($v['lastlogin']))
);
@$mail->send(); @$mail->send();
} }
@ -622,6 +740,9 @@ class Admin_UserController extends Zend_Controller_Action
$this->view->page = $page; $this->view->page = $page;
$this->view->url = "/admin/user/sendmail/ac/heihemail?now=".$start."&page=".$page;
return true;
} }
}//sendemailAction() }//sendemailAction()

View File

@ -6,4 +6,5 @@
<li><a href="/admin/user/group">用户组管理</a></li> <li><a href="/admin/user/group">用户组管理</a></li>
<li><a href="/admin/review/experts">元数据评审专家库</a></li> <li><a href="/admin/review/experts">元数据评审专家库</a></li>
<li><a href="/admin/user/sendmail/">长时间未登录用户</a></li> <li><a href="/admin/user/sendmail/">长时间未登录用户</a></li>
<li><a href="/admin/user/sendmail/ac/heihe">数字黑河用户</a></li>
</ul> </ul>

View File

@ -0,0 +1,70 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/admin.css');
$this->headLink()->appendStylesheet('/css/author.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin/">后台首页</a>');
$this->breadcrumb('<a href="/admin/user">用户管理</a>');
$this->breadcrumb()->setSeparator(' > ');
?>
<style>
.process {width:99%;height:20px;overflow:hidden;border:1px solid #6CF;}
.process .display { position:absolute;height:20px;color:#6CF; margin:0px; padding:0px;}
.process .np{display:block;height:20px;background-color:green;}
</style>
<div id="leftPanel">
<?= $this->partial('user/left.phtml'); ?>
</div>
<?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 id="rightPanel">
<?php
if(empty($this->stop)){ ?>
<?php
echo '<div class="process">';
echo '<div class="display">'.$this->percent.'%</div>';
echo '<div class="np" style="width:'.$this->percent.'%;"></div>';
echo '</div>';
?>
<div>
<a href="<?= $this->url;?>">如果页面没有跳转点击这里</a>
</div>
<div id="datalist">
<ul>
<?php
foreach($this->result as $v)
{
echo "<li>".$v['username'].' - '.$v['email'] . " - " . $v['lastlogin'] ."</li>\r\n";
}
?>
</ul>
</div>
<script>
function jump_url(){
self.location="<?php echo $this->url;?>";
}
function jump()
{
setTimeout("jump_url();",1000);
}
</script>
<?php
echo '<script>jump()</script>';
?>
<?php } else {
echo "邮件发送完成!";
}
?>
</div>

View File

@ -0,0 +1,54 @@
<?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/user">用户管理</a>');
$this->breadcrumb()->setSeparator(' > ');
?>
<div id="leftPanel">
<?= $this->partial('user/left.phtml'); ?>
</div>
<?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 id="rightPanel">
<div style="font-size:16px;line-height:30px;">数字黑河用户(共 <?= $this->count_users;?> 个)</div>
<div>
<button type="button" onclick="self.location='/admin/user/sendmail/ac/heihemail'" class="btn btn-green">发送邮件通知</button>
</div>
<table>
<thead>
<tr>
<td width='150'>用户名</td>
<td width='250'>电子邮箱</td>
<td width='150'>最后登录</td>
</tr>
</thead><!-- table's head -->
<?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><?= $item['username']?></td>
<td><?= $item['email']; ?></td>
<td><?= date("Y-m-d",strtotime($item['lastlogin'])); ?></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</table>
<div class="pagenavi"><?= $this->paginator; ?></div>
</div>