+ add api module.
This commit is contained in:
42
trunk/module/api/control.php
Normal file
42
trunk/module/api/control.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* The control file of api of ZenTaoMS.
|
||||
*
|
||||
* ZenTaoMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ZenTaoMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with ZenTaoMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @copyright Copyright 2009-2010 Chunsheng Wang
|
||||
* @author Chunsheng Wang <wwccss@263.net>
|
||||
* @package api
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.cn
|
||||
*/
|
||||
class api extends control
|
||||
{
|
||||
/* 获得sessionid。*/
|
||||
public function getSessionID()
|
||||
{
|
||||
$this->view->sessionID = session_id();
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/* 获得某一个model某一个方法的结果。params的传递方式:param1=value1,param2=value2。*/
|
||||
public function getModel($moduleName, $methodName, $params = '')
|
||||
{
|
||||
parse_str(str_replace(',', '&', $params), $params);
|
||||
$module = $this->loadModel($moduleName);
|
||||
$result = call_user_func_array(array(&$module, $methodName), $params);
|
||||
if(dao::isError()) die(json_encode(dao::getError()));
|
||||
die(json_encode($result));
|
||||
}
|
||||
}
|
||||
25
trunk/module/api/lang/zh-cn.php
Normal file
25
trunk/module/api/lang/zh-cn.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* The api module zh-cn file of ZenTaoMS.
|
||||
*
|
||||
* ZenTaoMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ZenTaoMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with ZenTaoMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @copyright Copyright 2009-2010 Chunsheng Wang
|
||||
* @author Chunsheng Wang <wwccss@263.net>
|
||||
* @package api
|
||||
* @version $Id: zh-cn.php 536 2010-03-17 06:39:06Z wwccss $
|
||||
* @link http://www.zentao.cn
|
||||
*/
|
||||
$lang->api->common = 'API接口';
|
||||
$lang->api->getModel = '超级model调用接口';
|
||||
@@ -53,6 +53,10 @@ class common extends control
|
||||
{
|
||||
if($method == 'login' or $method == 'logout' or $method == 'deny') return true;
|
||||
}
|
||||
elseif($module == 'api' and $method == 'getsessionid')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if(isset($this->app->user))
|
||||
{
|
||||
|
||||
@@ -200,9 +200,9 @@ $lang->resource->tree->ajaxGetOptionMenu = 'ajaxGetOptionMenu';
|
||||
$lang->resource->search->buildForm = 'buildForm';
|
||||
$lang->resource->search->buildQuery = 'buildQuery';
|
||||
|
||||
$lang->resource->api->getModel = 'getModel';
|
||||
$lang->resource->file->download = 'download';
|
||||
|
||||
$lang->resource->misc->ping = 'ping';
|
||||
$lang->resource->misc->ping = 'ping';
|
||||
|
||||
$lang->resource->admin->index = 'index';
|
||||
$lang->resource->admin->browseCompany = 'browseCompany';
|
||||
|
||||
@@ -71,8 +71,11 @@ class groupModel extends model
|
||||
/* 获得分组的用户列表。*/
|
||||
public function getUserPairs($groupID)
|
||||
{
|
||||
$sql = "SELECT T2.account, T2.realname FROM " . TABLE_USERGROUP . " AS T1 LEFT JOIN " . TABLE_USER . " AS T2 ON T1.account = T2.account WHERE `group` = '$groupID'";
|
||||
return $this->fetchPairs($sql);
|
||||
return $this->dao->select('t2.account, t2.realname')
|
||||
->from(TABLE_USERGROUP)->alias('t1')
|
||||
->leftJoin(TABLE_USER)->alias('t2')->on('t1.account = t2.account')
|
||||
->where('`group`')->eq((int)$groupID)
|
||||
->fetchPairs();
|
||||
}
|
||||
|
||||
/* 删除一个分组信息。*/
|
||||
|
||||
Reference in New Issue
Block a user