From 54c27d0dbf0ba8ffd2d56ba1eda41d1482965cb1 Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Tue, 6 Sep 2011 07:57:44 +0000 Subject: [PATCH] =?UTF-8?q?fix=20ticket=20#147,=20=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E7=94=A8=E6=88=B7=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controllers/UserController.php | 178 ++++++++++++++++++ application/admin/views/scripts/header.phtml | 3 +- .../admin/views/scripts/index/index.phtml | 1 + .../admin/views/scripts/user/adminlist.phtml | 50 +++++ .../admin/views/scripts/user/index.phtml | 26 +++ .../admin/views/scripts/user/list.phtml | 61 ++++++ .../admin/views/scripts/user/show.phtml | 74 ++++++++ 7 files changed, 391 insertions(+), 2 deletions(-) create mode 100755 application/admin/controllers/UserController.php create mode 100755 application/admin/views/scripts/user/adminlist.phtml create mode 100755 application/admin/views/scripts/user/index.phtml create mode 100755 application/admin/views/scripts/user/list.phtml create mode 100755 application/admin/views/scripts/user/show.phtml diff --git a/application/admin/controllers/UserController.php b/application/admin/controllers/UserController.php new file mode 100755 index 00000000..00e23b70 --- /dev/null +++ b/application/admin/controllers/UserController.php @@ -0,0 +1,178 @@ +db=Zend_Registry::get('db'); + $this->view->config = Zend_Registry::get('config'); + $this->messenger=$this->_helper->getHelper('FlashMessenger'); + $this->view->messages = $this->messenger->getMessages(); + } + function postDispatch() + { + $this->view->messages = $this->messenger->getMessages(); + } + function indexAction() + { + //其他连接 + } + + function listAction() + { + $select=$this->db->select(); + $select->from('users') + ->where('usertype = ?', 'member') + ->order('users.id desc'); + $paginator = Zend_Paginator::factory($select); + $paginator->setCurrentPageNumber($this->_getParam('page')); + $paginator->setItemCountPerPage(30); + $paginator->setView($this->view); + Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml'); + $this->view->paginator=$paginator; + } + + function deleteAction() + { + $delete=(int)$this->_getParam('id'); + $deletename = $this->_getParam('uname'); + + if (isset($delete)) + { + $sql="delete from users where id=?"; + try { + $this->db->query($sql,array($delete)); + $this->messenger->addMessage('您已经成功的删除了用户:'.$deletename); + } catch (Exception $e) { + $this->messenger->addMessage($e->getMessage()); + } + $this->_redirect("/admin/user/list"); + } + } + + function adminlistAction() + { + $select=$this->db->select(); + $select->from('users') + ->where('usertype = ?', 'administrator') + ->order('users.id desc'); + $paginator = Zend_Paginator::factory($select); + $paginator->setCurrentPageNumber($this->_getParam('page')); + $paginator->setItemCountPerPage(30); + $paginator->setView($this->view); + Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml'); + $this->view->paginator=$paginator; + } + + function showAction() + { + $id=(int)$this->_getParam('id'); + if (isset($id)) + { + try { + $sql="select * from users where id=?"; + $result=$this->db->query($sql,$id); + $rows = $result->fetch(); + $this->view->infos=$rows; + } catch (Exception $e) { + $this->messenger->addMessage($e->getMessage()); + } + } + else + { + $this->_redirect("/admin/user/list"); + } + } + + function editAction() + { + $id=(int)$this->_getParam('id'); + $usertype=$this->_getParam('usertype'); + $newpwd=$this->_getParam('newpwd'); + $cfnewpwd=$this->_getParam('cfnewpwd'); + $sql=""; + $updates=array(); + if (isset($id)) + { + if(!empty($newpwd)&&!empty($cfnewpwd)) + { + if($newpwd==$cfnewpwd) + { + $password=md5($newpwd); + $updates[]="password='$password'"; + } + else + { + $this->messenger->addMessage('两次密码不相同'); + $this->_redirect("/admin/user/show/id/$id"); + } + } + if(isset($usertype)) + { + $updates[]="usertype='$usertype'"; + } + + $update=join(',',$updates); + $sql="update users set $update where id='$id'"; + + try { + $this->db->query($sql); + $this->messenger->addMessage('编辑成功!'); + } catch (Exception $e) { + $this->messenger->addMessage($e->getMessage()); + } + $this->_redirect("/admin/user/show/id/$id"); + } + else { + $this->_redirect("/admin/user/list"); + } + + } + + function fetchpwdAction() + { + $id=(int)$this->_getParam('id'); + $email=$this->_getParam('email'); + if (!empty($email)) + { + try { + $sql="select * from users where email=?"; + $uq=$this->db->query($sql,$email); + if ($urow=$uq->fetch()) + { + //email the url to user + $username=$urow['username']; + $sql="update users set activation=? where email=?"; + $uid=uniqid(); + $this->db->query($sql,array($uid,$email)); + $mail=new WestdcMailer($this->view->config->smtp); + $body="尊敬的西部数据中心用户: + 有人提出了针对此用户名的密码重置请求。 + + 用户名:"; + $body.=$username; + $body.=" + + 若想重置您的密码请打开下面的链接,否则请忽略此邮件,一切如常。 +"; + $body.="http://westdc.westgis.ac.cn/account/fetchpwd/".$username."/".$uid; + $mail->setBodyText($body); + $mail->setFrom($this->view->config->service->email,'西部数据中心服务组'); + $mail->addTo($email); + $mail->setSubject('密码已重置'); + $mail->send(); + $this->messenger->addMessage('密码重置成功!'); + } + } catch (Exception $e) { + $this->messenger->addMessage($e->getMessage().$email); + } + $this->_redirect("/admin/user/show/id/$id"); + } + else { + $this->_redirect("/admin/user/list"); + } + + } + + //overview +} + diff --git a/application/admin/views/scripts/header.phtml b/application/admin/views/scripts/header.phtml index fcb15a78..02566463 100755 --- a/application/admin/views/scripts/header.phtml +++ b/application/admin/views/scripts/header.phtml @@ -8,8 +8,7 @@
  • 后台首页
  • 数据管理
  • 申请管理
  • - -
  • 用户管理
  • +
  • 用户管理
  • 统计数据
  • diff --git a/application/admin/views/scripts/index/index.phtml b/application/admin/views/scripts/index/index.phtml index 08c83777..0173f6a2 100755 --- a/application/admin/views/scripts/index/index.phtml +++ b/application/admin/views/scripts/index/index.phtml @@ -20,6 +20,7 @@
  • WATER元数据处理工具
  • 数据测试管理
  • 数据库工具
  • +
  • 用户管理
  • diff --git a/application/admin/views/scripts/user/adminlist.phtml b/application/admin/views/scripts/user/adminlist.phtml new file mode 100755 index 00000000..043da090 --- /dev/null +++ b/application/admin/views/scripts/user/adminlist.phtml @@ -0,0 +1,50 @@ +headTitle($this->config->title->site); + $this->headTitle('后台管理'); + $this->headTitle()->setSeparator(' - '); + $this->headLink()->appendStylesheet('/css/admin.css'); + $this->breadcrumb('首页'); + $this->breadcrumb('后台管理首页'); + $this->breadcrumb()->setSeparator(' > '); +?> +
    + +
    +用户管理工具: + + +
    + +
    + + + + + + + + + +paginator)): ?> +paginator as $item): ?> + + + + + + + + + + +
    用户名电子邮箱用户类型真实姓名电话操作
    +'>查看详细 +
    +
    +paginator; ?> +
    + +
    \ No newline at end of file diff --git a/application/admin/views/scripts/user/index.phtml b/application/admin/views/scripts/user/index.phtml new file mode 100755 index 00000000..e6c9a779 --- /dev/null +++ b/application/admin/views/scripts/user/index.phtml @@ -0,0 +1,26 @@ +headTitle($this->config->title->site); + $this->headTitle('后台管理'); + $this->headTitle()->setSeparator(' - '); + $this->headLink()->appendStylesheet('/css/admin.css'); + $this->breadcrumb('首页'); + $this->breadcrumb('后台管理首页'); + $this->breadcrumb()->setSeparator(' > '); +?> +
    + +
    +用户管理工具: + + +
    + +
    + + +
    + +
    \ No newline at end of file diff --git a/application/admin/views/scripts/user/list.phtml b/application/admin/views/scripts/user/list.phtml new file mode 100755 index 00000000..9f85b88b --- /dev/null +++ b/application/admin/views/scripts/user/list.phtml @@ -0,0 +1,61 @@ +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(' > '); +?> +
    + +
    +用户管理工具: + +
    + +msg or $this->messages) :?> +
    +msg) : ?> +

    msg; ?>

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

    + +
    + + + +
    + + + + + + + + +paginator)): ?> +paginator as $item): ?> + + + + + + + + + +
    用户名电子邮箱用户类型真实姓名操作
    +/uname/' onclick="return confirm('确定将此记录删除?')">删除 +'>查看详细 +/id/' onclick="return confirm('是否确定为他重置密码?')">重置密码 +
    +
    +paginator; ?> +
    + +
    \ No newline at end of file diff --git a/application/admin/views/scripts/user/show.phtml b/application/admin/views/scripts/user/show.phtml new file mode 100755 index 00000000..e874b503 --- /dev/null +++ b/application/admin/views/scripts/user/show.phtml @@ -0,0 +1,74 @@ +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(' > '); +?> +
    + +
    +用户管理工具: + +
    + +msg or $this->messages) :?> +
    +msg) : ?> +

    msg; ?>

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

    + +
    + + +
    +
    + + + + + + + + + + + + + + +
    IDinfos['id'];?>
    用户名infos['username'];?>
    真实姓名infos['realname'];?>
    电子邮箱infos['email'];?>
    注册时间infos['ts_created'];?>
    最后登陆时间infos['ts_last_login'];?>
    单位infos['unit'];?>
    地址infos['address'];?>
    电话infos['phone'];?>
    项目infos['project'];?>
    用户权限 + +
    用户密码
    确认用户密码
    + + +
    +
    + + + +
    +
    \ No newline at end of file