From ceaf16e572632ea9bd1b7ae88207278ce471ba51 Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Mon, 10 Dec 2012 09:30:38 +0000 Subject: [PATCH] =?UTF-8?q?#437=20=E6=B7=BB=E5=8A=A0=E4=BA=86=E9=95=BF?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=9C=AA=E7=99=BB=E5=BD=95=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=9A=84=E9=82=80=E8=AF=B7=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controllers/UserController.php | 123 ++++++++++++++++++ .../admin/views/scripts/user/left.phtml | 1 + .../views/scripts/user/sendmail-send.phtml | 70 ++++++++++ .../admin/views/scripts/user/sendmail.phtml | 60 +++++++++ 4 files changed, 254 insertions(+) create mode 100644 application/admin/views/scripts/user/sendmail-send.phtml create mode 100644 application/admin/views/scripts/user/sendmail.phtml diff --git a/application/admin/controllers/UserController.php b/application/admin/controllers/UserController.php index 43045e38..5f72e5d4 100755 --- a/application/admin/controllers/UserController.php +++ b/application/admin/controllers/UserController.php @@ -496,6 +496,129 @@ class Admin_UserController extends Zend_Controller_Action }// groupAction() + /* + * + * 给时间长没有登录的用户发送邀请邮件 + * + */ + public function sendmailAction(){ + + $ac = $this->_getParam('ac'); + + if(empty($ac) || $ac=='index') + { + $time = date("Y-m-d H:i:s",time()-3*365*24*3600); + + $sql = "SELECT * FROM users + WHERE ts_last_login<'$time' + ORDER BY ts_last_login 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); + } + + if($ac == "send") + { + $this->_helper->viewRenderer('sendmail-send'); + + //当前进行到的数量 + $now = $this->_getParam('now'); + + //需要将起始的时间传递过来,防止sql中出现多余的用户 + $time = $this->_getParam('time'); + if(empty($time)) + { + $time = date("Y-m-d H:i:s",time()-3*365*24*3600); + } + $this->view->gotime = $time; + + //当前处理的页数 + $page = $this->_getParam('page'); + if(empty($page)) + { + $page = 0; + } + + $step = 20; + + $sql = "SELECT count(id) as c FROM users + WHERE ts_last_login<'$time'"; + + $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"; + return true; + } + + $sql = "SELECT * FROM users + WHERE ts_last_login<'$time' + ORDER BY ts_last_login 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,"author-new",array( + 'user' => $v['username'], + 'uid' => $v['id'], + 'realname'=> $v['realname'], + 'lastlogin'=> date("Y-m-d",$v['email']), + )); + $mail->setBodyText($mailtp->getBody()); + $mail->setSubject($mailtp->getSubject()); + @$mail->addTo($v['email']); + $result[$v['id']] = array( + 'username'=>$v['username'], + 'email'=>$v['email'] + ); + @$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; + + } + + }//sendemailAction() + diff --git a/application/admin/views/scripts/user/left.phtml b/application/admin/views/scripts/user/left.phtml index b0e61f5b..ff5d3990 100755 --- a/application/admin/views/scripts/user/left.phtml +++ b/application/admin/views/scripts/user/left.phtml @@ -5,4 +5,5 @@
  • 管理员列表
  • 用户组管理
  • 元数据评审专家库
  • +
  • 长时间未登录用户
  • \ No newline at end of file diff --git a/application/admin/views/scripts/user/sendmail-send.phtml b/application/admin/views/scripts/user/sendmail-send.phtml new file mode 100644 index 00000000..60bdb1c2 --- /dev/null +++ b/application/admin/views/scripts/user/sendmail-send.phtml @@ -0,0 +1,70 @@ +headTitle($this->config->title->site); + $this->headTitle('后台管理'); + $this->headTitle()->setSeparator(' - '); + $this->headLink()->appendStylesheet('/css/admin.css'); + $this->headLink()->appendStylesheet('/css/author.css'); + $this->breadcrumb('首页'); + $this->breadcrumb('后台首页'); + $this->breadcrumb('用户管理'); + $this->breadcrumb()->setSeparator(' > '); +?> + +
    +partial('user/left.phtml'); ?> +
    + +msg or $this->messages) :?> +
    +msg) : ?> +

    msg; ?>

    +messages): foreach($this->messages as $msg): ?> +

    + +
    + + + +
    +stop)){ ?> +'; +echo '
    '.$this->percent.'%
    '; +echo '
    '; +echo '
    '; +?> +
    + +
    + +jump("'.$this->now.'","'.$this->page.'","'.$this->gotime.'")'; +?> + + \ No newline at end of file diff --git a/application/admin/views/scripts/user/sendmail.phtml b/application/admin/views/scripts/user/sendmail.phtml new file mode 100644 index 00000000..f8c61e1c --- /dev/null +++ b/application/admin/views/scripts/user/sendmail.phtml @@ -0,0 +1,60 @@ +headTitle($this->config->title->site); + $this->headTitle('后台管理'); + $this->headTitle()->setSeparator(' - '); + $this->headLink()->appendStylesheet('/css/admin.css'); + $this->breadcrumb('首页'); + $this->breadcrumb('后台首页'); + $this->breadcrumb('用户管理'); + $this->breadcrumb()->setSeparator(' > '); +?> +
    +partial('user/left.phtml'); ?> +
    + +msg or $this->messages) :?> +
    +msg) : ?> +

    msg; ?>

    +messages): foreach($this->messages as $msg): ?> +

    + +
    + + + +
    +
    3年内未登录的用户列表(共 count_users;?> 个)
    + +
    + +
    + + + + + + + + + + + + +paginator)): ?> + +paginator as $item): ?> + + + + + + + + + + + +
    用户名电子邮箱用户类型单位真实姓名最后登录
    + +
    \ No newline at end of file