fix ticket #306, 实现geonetwork的自动登录跳转

This commit is contained in:
wlx 2012-03-15 12:42:23 +00:00
parent b72da31e50
commit 2a055c74f8
1 changed files with 36 additions and 1 deletions

View File

@ -1211,5 +1211,40 @@ class ServiceController extends Zend_Controller_Action
}
echo '</ul>';
echo $pagnation;
}//文档页面相关数据
}//文档页面相关数据
function geonetwork()
{
$this->_helper->viewRenderer->setNoRender();
$this->_helper->layout->disableLayout();
$auth = Zend_Auth::getInstance();
if (!$auth->hasIdentity())
exit();
$user = $auth->getIdentity();
//need to get pwd from database
$sql='select username,md5(password) as pwd from users where id='.$user->id;
$row=$this->db->fetchRow($sql);
$login=$this->config->geonetwork->url.'/srv/en/xml.user.login?username='.$row->username.'&password='.$row->pwd;
$url = $this->_request->getParam('url');
if empty($url)
$url='/geonetwork/srv/cn/';
$body='<html>
<script type="text/javascript" src="/js/jquery-1.7.min.js"></script>
<script type="text/javascript">
var b = null;
$(document).ready(function() {
$.get(
"'.$login.'",
{},
function(data){
var url = "'.$url.'";
$(location).attr("href",url);
}
);
});
</script>
<body></body>
</html>';
$this->getResponse()->setHeader('Content-Type', 'text/html')
->setBody($body);
}
}