From 4381b008ae795b923f25023614f5a7699be704a3 Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Tue, 25 Mar 2014 09:21:28 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=8C=E6=AD=A5=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=91=98=E5=88=B0geonetwork=E7=9A=84=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controllers/UserController.php | 35 +++++++ .../admin/views/scripts/user/adminlist.phtml | 91 ++++++++++--------- application/module/Helpers/PDO.php | 45 +++++++++ 3 files changed, 126 insertions(+), 45 deletions(-) create mode 100644 application/module/Helpers/PDO.php diff --git a/application/admin/controllers/UserController.php b/application/admin/controllers/UserController.php index 9106f7c7..49817eb4 100755 --- a/application/admin/controllers/UserController.php +++ b/application/admin/controllers/UserController.php @@ -1,4 +1,6 @@ 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; + + $ac = $this->_getParam('ac'); + + if($ac == 'sync') + { + $sql = "SELECT id FROM users WHERE usertype='administrator'"; + $rs = $this->db->query($sql); + $ids = $rs->fetchAll(); + + $data = array(); + foreach($ids as $v) + { + $data[] = $v['id']; + } + unset($ids); + + $ids = join(",",$data); + + $gn_sql = "update users set profile='Administrator' where id in ($ids)"; + $gn_db = new PDO(array( + 'host'=> $this->view->config->geonetwork->params->host, + 'port' => 5432, + 'user' => $this->view->config->geonetwork->params->username, + 'pwd' => $this->view->config->geonetwork->params->password , + 'db' => $this->view->config->geonetwork->params->dbname + )); + + $gn_db->exec($gn_sql); + + view::Post($this,"同步成功!",-1); + } } function showAction() diff --git a/application/admin/views/scripts/user/adminlist.phtml b/application/admin/views/scripts/user/adminlist.phtml index 115fc724..3606ba74 100755 --- a/application/admin/views/scripts/user/adminlist.phtml +++ b/application/admin/views/scripts/user/adminlist.phtml @@ -1,46 +1,47 @@ -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'); ?> -
- -
-
管理员列表
- - - - - - - - - - - -paginator)): ?> - -paginator as $item): ?> - - - - - - - - - - - -
用户名电子邮箱用户类型真实姓名电话操作
-'>查看详细 -
- +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'); ?> +
+ +
+
管理员列表
+
同步管理员到geonetwork
+ + + + + + + + + + + +paginator)): ?> + +paginator as $item): ?> + + + + + + + + + + + +
用户名电子邮箱用户类型真实姓名电话操作
+'>查看详细 +
+
\ No newline at end of file diff --git a/application/module/Helpers/PDO.php b/application/module/Helpers/PDO.php new file mode 100644 index 00000000..d41733c4 --- /dev/null +++ b/application/module/Helpers/PDO.php @@ -0,0 +1,45 @@ +config_local_path); + $dsn = "pgsql:host={$config_local->db->hostname};" + ."port=5432;" + ."dbname={$config_local->db->database};" + ."user={$config_local->db->username};" + ."password={$config_local->db->password}"; + parent::__construct($dsn); + } + + else{ + + if(is_string($DSN)) + { + parent::__construct($DSN); + } + + else{ + $dsn = "pgsql:host={$DSN['host']};" + ."port={$DSN['port']};" + ."dbname={$DSN['db']};" + ."user={$DSN['user']};" + ."password={$DSN['pwd']}"; + parent::__construct($dsn); + } + + } + } + +} \ No newline at end of file