添加同步管理员到geonetwork的功能
This commit is contained in:
parent
72c353f435
commit
4381b008ae
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
use Helpers\View as view;
|
||||
use Helpers\PDO;
|
||||
class Admin_UserController extends Zend_Controller_Action
|
||||
{
|
||||
function preDispatch()
|
||||
|
@ -117,12 +119,45 @@ class Admin_UserController extends Zend_Controller_Action
|
|||
$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;
|
||||
|
||||
$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()
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
<div id="rightPanel">
|
||||
<div class="title">管理员列表</div>
|
||||
<div class=""><a href="/admin/user/adminlist/ac/sync">同步管理员到geonetwork</a></div>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
namespace Helpers;
|
||||
|
||||
class PDO extends \PDO
|
||||
{
|
||||
private $debug = 0; //调试模式
|
||||
|
||||
private $config_local_path = "config/autoload/local.php";
|
||||
|
||||
public $db_cfg;
|
||||
|
||||
function __construct($DSN = NULL)
|
||||
{
|
||||
|
||||
if(empty($DSN))
|
||||
{
|
||||
$config_local = new Zend_Config(include $this->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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue