From 8657471e7307e11f529f8e9ddff63652cdb323aa Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Mon, 3 Mar 2014 09:10:04 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BC=9A=E5=91=98=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/Admin/config/module.config.php | 160 ++++++++-------- .../src/Admin/Controller/UsersController.php | 98 ++++++++++ module/Admin/view/admin/users/index.phtml | 84 +++++++++ module/Admin/view/admin/users/nav.phtml | 6 + module/Admin/view/admin/users/view.phtml | 66 +++++++ module/Admin/view/layout/header.phtml | 3 +- vendor/Sookon/Authentication/AclResource.php | 171 +++++++++--------- vendor/Westdc/Member/Member.php | 117 ++++++++++++ 8 files changed, 540 insertions(+), 165 deletions(-) create mode 100644 module/Admin/src/Admin/Controller/UsersController.php create mode 100644 module/Admin/view/admin/users/index.phtml create mode 100644 module/Admin/view/admin/users/nav.phtml create mode 100644 module/Admin/view/admin/users/view.phtml create mode 100644 vendor/Westdc/Member/Member.php diff --git a/module/Admin/config/module.config.php b/module/Admin/config/module.config.php index e8f516d8..23921f41 100644 --- a/module/Admin/config/module.config.php +++ b/module/Admin/config/module.config.php @@ -1,78 +1,82 @@ - array( - 'services' => array( - //'Auth' => new Sookon\Authentication\AuthenticationService(), - ), - ), - - 'controllers' => array( - 'invokables' => array( - 'Admin\Controller\Index' => 'Admin\Controller\IndexController', - 'Admin\Controller\Article' => 'Admin\Controller\ArticleController', - 'Admin\Controller\Category' => 'Admin\Controller\CategoryController', - 'Admin\Controller\Metadata' => 'Admin\Controller\MetadataController', - ), - ), - - 'router' => array( - 'routes' => array( - 'admin' => array( - 'type' => 'Segment', - 'options' => array( - 'route' => '/admin[/:controller[/:action[/:ac][/page/:page][/id/:id]]]', - 'constraints' => array( - 'controller' => '[a-zA-Z][a-zA-Z0-9_-]*', - 'action' => '[a-zA-Z][a-zA-Z0-9_-]*', - 'ac' => '[a-zA-Z][a-zA-Z0-9_-]*', - 'page' => '[a-zA-Z][a-zA-Z0-9_-]*', - 'id' => '[a-zA-Z][a-zA-Z0-9_-]*', - ), - 'defaults' => array( - 'module' => 'Admin', - '__NAMESPACE__' => 'Admin\Controller', - 'controller' => 'Admin\Controller\Index', - 'action' => 'index', - ), - ), - 'may_terminate' => true, - 'child_routes' => array( - 'wildcard' => array( - 'type' => 'Wildcard' - ) - ) - ), - ), - ), - - 'view_manager' => array( - 'template_path_stack' => array( - 'admin' => __DIR__ . '/../view', - ), - 'template_map' => array( - 'layout/admin' => __DIR__ . '/../view/layout/admin.phtml', - 'layout/admin/header' => __DIR__ . '/../view/layout/header.phtml', - 'layout/admin/pagination' => __DIR__ . '/../view/layout/pagination.phtml', - - 'layout/admin/article/list' => __DIR__ . '/../view/admin/article/list.phtml', - 'layout/admin/article/nav' => __DIR__ . '/../view/admin/article/nav.phtml', - 'layout/admin/article/add' => __DIR__ . '/../view/admin/article/add.phtml', - - 'layout/admin/category/list' => __DIR__ . '/../view/admin/category/list.phtml', - 'layout/admin/category/nav' => __DIR__ . '/../view/admin/category/nav.phtml', - 'layout/admin/category/add' => __DIR__ . '/../view/admin/category/add.phtml', - 'layout/admin/category/moved' => __DIR__ . '/../view/admin/category/moved.phtml', - - 'layout/admin/metadata/list' => __DIR__ . '/../view/admin/metadata/list.phtml', - 'layout/admin/metadata/nav' => __DIR__ . '/../view/admin/metadata/nav.phtml', - ), - ), -); + array( + 'services' => array( + //'Auth' => new Sookon\Authentication\AuthenticationService(), + ), + ), + + 'controllers' => array( + 'invokables' => array( + 'Admin\Controller\Index' => 'Admin\Controller\IndexController', + 'Admin\Controller\Article' => 'Admin\Controller\ArticleController', + 'Admin\Controller\Category' => 'Admin\Controller\CategoryController', + 'Admin\Controller\Metadata' => 'Admin\Controller\MetadataController', + 'Admin\Controller\Users' => 'Admin\Controller\UsersController', + ), + ), + + 'router' => array( + 'routes' => array( + 'admin' => array( + 'type' => 'Segment', + 'options' => array( + 'route' => '/admin[/:controller[/:action[/:ac][/page/:page][/id/:id]]]', + 'constraints' => array( + 'controller' => '[a-zA-Z][a-zA-Z0-9_-]*', + 'action' => '[a-zA-Z][a-zA-Z0-9_-]*', + 'ac' => '[a-zA-Z][a-zA-Z0-9_-]*', + 'page' => '[a-zA-Z][a-zA-Z0-9_-]*', + 'id' => '[a-zA-Z][a-zA-Z0-9_-]*', + ), + 'defaults' => array( + 'module' => 'Admin', + '__NAMESPACE__' => 'Admin\Controller', + 'controller' => 'Admin\Controller\Index', + 'action' => 'index', + ), + ), + 'may_terminate' => true, + 'child_routes' => array( + 'wildcard' => array( + 'type' => 'Wildcard' + ) + ) + ), + ), + ), + + 'view_manager' => array( + 'template_path_stack' => array( + 'admin' => __DIR__ . '/../view', + ), + 'template_map' => array( + 'layout/admin' => __DIR__ . '/../view/layout/admin.phtml', + 'layout/admin/header' => __DIR__ . '/../view/layout/header.phtml', + 'layout/admin/pagination' => __DIR__ . '/../view/layout/pagination.phtml', + + 'layout/admin/article/list' => __DIR__ . '/../view/admin/article/list.phtml', + 'layout/admin/article/nav' => __DIR__ . '/../view/admin/article/nav.phtml', + 'layout/admin/article/add' => __DIR__ . '/../view/admin/article/add.phtml', + + 'layout/admin/category/list' => __DIR__ . '/../view/admin/category/list.phtml', + 'layout/admin/category/nav' => __DIR__ . '/../view/admin/category/nav.phtml', + 'layout/admin/category/add' => __DIR__ . '/../view/admin/category/add.phtml', + 'layout/admin/category/moved' => __DIR__ . '/../view/admin/category/moved.phtml', + + 'layout/admin/metadata/list' => __DIR__ . '/../view/admin/metadata/list.phtml', + 'layout/admin/metadata/nav' => __DIR__ . '/../view/admin/metadata/nav.phtml', + + 'layout/admin/users/list' => __DIR__ . '/../view/admin/users/list.phtml', + 'layout/admin/users/nav' => __DIR__ . '/../view/admin/users/nav.phtml', + ), + ), +); diff --git a/module/Admin/src/Admin/Controller/UsersController.php b/module/Admin/src/Admin/Controller/UsersController.php new file mode 100644 index 00000000..f5124a7a --- /dev/null +++ b/module/Admin/src/Admin/Controller/UsersController.php @@ -0,0 +1,98 @@ +ViewModel = new ViewModel(); + } + + public function indexAction() + { + $users = new \Westdc\Member\Member; + + $filter = new \Sookon\Search\Filter; + + $keyword = isset($_GET['q']) ? $filter->mixedKeyword($_GET['q']):""; + if(!empty($keyword)) + { + $this->ViewModel->setVariable('keyword',$keyword); + $users->opt->logic = "OR"; + + if(!is_numeric($keyword)) + { + $users->opt->where = array( + "m.username LIKE '%$keyword%'", + "m.realname LIKE '%$keyword%'", + "m.unit LIKE '%$keyword%'", + "m.project LIKE '%$keyword%'", + "m.email LIKE '%$keyword%'", + "m.project_leader LIKE '%$keyword%'", + "m.project_id LIKE '%$keyword%'", + "m.project_type LIKE '%$keyword%'", + "m.project_title LIKE '%$keyword%'", + "m.address LIKE '%$keyword%'", + "m.phone LIKE '%$keyword%'", + ); + } + else + $users->opt->where = array( + "m.id=$keyword", + ); + + } + + view::addPaginator($users->fetchAll(),$this,18); + + return $this->ViewModel; + } + + public function viewAction() + { + $id = $this->params()->fromRoute('id'); + + if(empty($id) || !is_numeric($id)) + { + return view::Post($this,"参数错误",-1); + } + + $users = new \Westdc\Member\Member; + + $this->ViewModel->setVariable("data",$users->fetch($id)); + + return $this->ViewModel; + } + + public function editAction() + { + $id = $this->params()->fromRoute('id'); + + if(empty($id) || !is_numeric($id)) + { + return view::Post($this,"参数错误",-1); + } + + $ac = $this->params()->fromRoute('ac'); + + if($ac == "reset") + { + + } + } +} diff --git a/module/Admin/view/admin/users/index.phtml b/module/Admin/view/admin/users/index.phtml new file mode 100644 index 00000000..cd1ae99a --- /dev/null +++ b/module/Admin/view/admin/users/index.phtml @@ -0,0 +1,84 @@ + +
+ +
+
+
+ +

所有记录

+
+
+ +
+
+
+
+ "> + + + +
+
+
+ +
+ + paginator)) { ?> + + + + + + + + + + + + + paginator as $v) { ?> + + + + + + + + + + +
id用户名姓名单位Email添加时间操作
+ + + + + + +
+ + + 暂无信息 + + +
+ paginator)) { ?> + + +
+ +
+ +
+ partial("layout/admin/users/nav") ?> +
+ +
\ No newline at end of file diff --git a/module/Admin/view/admin/users/nav.phtml b/module/Admin/view/admin/users/nav.phtml new file mode 100644 index 00000000..f3e3144b --- /dev/null +++ b/module/Admin/view/admin/users/nav.phtml @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/module/Admin/view/admin/users/view.phtml b/module/Admin/view/admin/users/view.phtml new file mode 100644 index 00000000..652634fd --- /dev/null +++ b/module/Admin/view/admin/users/view.phtml @@ -0,0 +1,66 @@ + +
+ +
+ +

data['username'] ?> data['realname'] ?>

+ +
+
ID
+
data['id'] ?>
+ +
用户名
+
data['username'] ?>
+ +
真实姓名
+
data['realname'] ?>
+ +
Email
+
data['email'] ?>
+ +
单位
+
data['unit'] ?>
+ +
地址
+
data['address'] ?>
+ +
电话
+
data['phone'] ?>
+ +
邮编
+
data['postcode'] ?>
+ +
项目名称
+
data['project_title'] ?>
+ +
项目编号
+
data['project_id'] ?>
+ +
项目类型
+
data['project_type'] ?>
+ +
项目
+
data['project'] ?>
+ +
项目负责人
+
data['project_leader'] ?>
+ +
注册时间
+
data['ts_created'] ?>
+ +
最后登录
+
data['ts_last_login'] ?>
+ +
+ + + +
+ +
+ partial("layout/admin/users/nav") ?> +
+ +
\ No newline at end of file diff --git a/module/Admin/view/layout/header.phtml b/module/Admin/view/layout/header.phtml index 91933d51..99d64f8a 100644 --- a/module/Admin/view/layout/header.phtml +++ b/module/Admin/view/layout/header.phtml @@ -27,9 +27,8 @@ diff --git a/vendor/Sookon/Authentication/AclResource.php b/vendor/Sookon/Authentication/AclResource.php index aa7fbd11..852829c2 100644 --- a/vendor/Sookon/Authentication/AclResource.php +++ b/vendor/Sookon/Authentication/AclResource.php @@ -1,86 +1,87 @@ - array( - 'login', - 'logout', - 'register', - 'forgotpassword', - 'getpassword', - 'captcha', - 'index' - ), - - //service - 'Application\Controller\Service' => array( - 'upload', - 'delatt', - 'thumb', - 'bigthumb' - ), - - 'Article\Controller\Article' => array( - 'index', - 'view' - ), - - 'Article\Controller\Category' => array( - 'index', - 'list' - ), - - 'Metadata\Controller\Index', - ); - - function __construct(Acl &$acl) - { - $this->acl = $acl; - - $this->loadResource(); - - $acl = $this->acl; - } - - public function loadResource() - { - foreach($this->config as $index => $resource) - { - if(!is_array($resource)) - { - $this->acl->addResource(new Resource($resource)); - continue; - } - - $this->acl->addResource(new Resource($index)); - - foreach($resource as $action) - { - if($this->acl->hasResource($action)) - { - continue; - } - - $this->acl->addResource(new Resource($action),$index); - } - } - } - + array( + 'login', + 'logout', + 'register', + 'forgotpassword', + 'getpassword', + 'captcha', + 'index' + ), + + //service + 'Application\Controller\Service' => array( + 'upload', + 'delatt', + 'thumb', + 'bigthumb' + ), + + 'Article\Controller\Article' => array( + 'index', + 'view' + ), + + 'Article\Controller\Category' => array( + 'index', + 'list' + ), + + 'Metadata\Controller\Index', + ); + + function __construct(Acl &$acl) + { + $this->acl = $acl; + + $this->loadResource(); + + $acl = $this->acl; + } + + public function loadResource() + { + foreach($this->config as $index => $resource) + { + if(!is_array($resource)) + { + $this->acl->addResource(new Resource($resource)); + continue; + } + + $this->acl->addResource(new Resource($index)); + + foreach($resource as $action) + { + if($this->acl->hasResource($action)) + { + continue; + } + + $this->acl->addResource(new Resource($action),$index); + } + } + } + } \ No newline at end of file diff --git a/vendor/Westdc/Member/Member.php b/vendor/Westdc/Member/Member.php new file mode 100644 index 00000000..f8a94efe --- /dev/null +++ b/vendor/Westdc/Member/Member.php @@ -0,0 +1,117 @@ +db = new Pdo; + $this->config = Config::get(); + $this->table = new Table; + + $this->opt = new \stdClass(); + + $this->opt->sort = "DESC"; + $this->opt->logic = "AND"; + } + + public function fetchAll() + { + $wheresql = array(); + + if(isset($this->opt->where) && !empty($this->opt->where)) + $wheresql = array_merge($wheresql,$this->opt->where); + + if(count($wheresql)>0) + { + $wheresql = " WHERE \r\n ".join($wheresql," ".$this->opt->logic." \r\n "); + }else{ + $wheresql = ''; + } + + if(!empty($this->opt->order)) + { + $order = $this->opt->order; + }else{ + $order = "m.id"; + } + + $sql = "SELECT + m.* + FROM {$this->table->member} m + $wheresql + ORDER BY $order {$this->opt->sort}"; + + if(!empty($this->opt->start)) + { + $sql .= " START {$this->opt->start} "; + } + + if(!empty($this->opt->limit)){ + $sql .= " LIMIT {$this->opt->limit} "; + } + + $rs = $this->db->query($sql); + return $rs->fetchAll(); + } + + public function fetch($id) + { + if(is_numeric($id)) + { + $sql = "SELECT * FROM {$this->table->member} WHERE id=$id"; + }else if(\Sookon\Helpers\Uuid::test($id)){ + $sql = "SELECT * FROM {$this->table->member} WHERE uuid='$id'"; + }else{ + return false; + } + + $rs = $this->db->query($sql); + return $rs->fetch(); + } + + public function resetPassword($id) + { + $user = $this->fetch($id); + + if(empty($user)) + { + return "参数错误"; + } + + $activetion = uniqid(); + + $sql = "UPDATE {$this->table->member} SET activation='$activetion' WHERE id=$id"; + $state = $this->db->exec($sql); + + if($state) + { + $data = array( + 'user' => empty($user['realname']) ? $user['username'] : $user['realname'], + 'username' => $user['username'], + 'url' => view::getHostLink()."/account/fetchpwd/".$username."/".$activetion + ); + + + }else{ + return false; + } + } + + +} \ No newline at end of file