diff --git a/module/api/control.php b/module/api/control.php index f7947e6b21..6711f0db26 100755 --- a/module/api/control.php +++ b/module/api/control.php @@ -325,16 +325,8 @@ class api extends control return $this->sendSuccess(array('locate' => $this->createLink('api', 'index', "libID=$libID"))); } - $lib = fixer::input('post') - ->join('groups', ',') - ->join('users', ',') - ->get(); - - if($lib->acl == 'private') $lib->users = $this->app->user->account; - if($lib->acl == 'custom' && strpos($lib->users, $this->app->user->account) === false) $lib->users .= ',' . $this->app->user->account; - /* save api doc library */ - $libID = $this->doc->createApiLib($lib); + $libID = $this->doc->createApiLib(); if(dao::isError()) { return $this->sendError(dao::getError()); diff --git a/module/doc/lang/en.php b/module/doc/lang/en.php index 1f5c138078..263a30f556 100644 --- a/module/doc/lang/en.php +++ b/module/doc/lang/en.php @@ -229,15 +229,16 @@ $lang->doc->ge = ':'; $lang->doc->point = '.'; $lang->doclib = new stdclass(); -$lang->doclib->name = 'Name'; -$lang->doclib->control = 'Access Control'; -$lang->doclib->group = 'Group'; -$lang->doclib->user = 'User'; -$lang->doclib->files = 'Attachments'; -$lang->doclib->all = 'All Libraries'; -$lang->doclib->select = 'Select'; -$lang->doclib->execution = $lang->executionCommon . ' Library'; -$lang->doclib->product = $lang->productCommon . ' Library'; +$lang->doclib->name = 'Name'; +$lang->doclib->control = 'Access Control'; +$lang->doclib->group = 'Group'; +$lang->doclib->user = 'User'; +$lang->doclib->files = 'Attachments'; +$lang->doclib->all = 'All Libraries'; +$lang->doclib->select = 'Select'; +$lang->doclib->execution = $lang->executionCommon . ' Library'; +$lang->doclib->product = $lang->productCommon . ' Library'; +$lang->doclib->apiLibName = 'Api Library Name'; $lang->doclib->aclListA['default'] = 'Default'; $lang->doclib->aclListA['custom'] = 'Custom'; diff --git a/module/doc/lang/zh-cn.php b/module/doc/lang/zh-cn.php index f929a40d98..cfbd42c599 100644 --- a/module/doc/lang/zh-cn.php +++ b/module/doc/lang/zh-cn.php @@ -229,15 +229,16 @@ $lang->doc->ge = '个'; $lang->doc->point = '、'; $lang->doclib = new stdclass(); -$lang->doclib->name = '文档库名称'; -$lang->doclib->control = '访问控制'; -$lang->doclib->group = '分组'; -$lang->doclib->user = '用户'; -$lang->doclib->files = '附件库'; -$lang->doclib->all = '所有文档库'; -$lang->doclib->select = '选择文档库'; -$lang->doclib->execution = $lang->executionCommon . '库'; -$lang->doclib->product = $lang->productCommon . '库'; +$lang->doclib->name = '文档库名称'; +$lang->doclib->control = '访问控制'; +$lang->doclib->group = '分组'; +$lang->doclib->user = '用户'; +$lang->doclib->files = '附件库'; +$lang->doclib->all = '所有文档库'; +$lang->doclib->select = '选择文档库'; +$lang->doclib->execution = $lang->executionCommon . '库'; +$lang->doclib->product = $lang->productCommon . '库'; +$lang->doclib->apiLibName = '接口库名称'; $lang->doclib->aclListA['default'] = '默认'; $lang->doclib->aclListA['custom'] = '自定义'; diff --git a/module/doc/model.php b/module/doc/model.php index 67ae6e2a1c..c3cbdba155 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -196,20 +196,29 @@ class docModel extends model /** * creat a api doc library. * - * @param stdClass $data form data. * @return int * @author thanatos thanatos915@163.com */ - public function createApiLib($data) + public function createApiLib() { /* replace doc library name */ - $this->lang->doclib->name = '接口库名称'; + $this->lang->doclib->name = $this->lang->doclib->apiLibName; + + $data = fixer::input('post') + ->trim('name') + ->join('groups', ',') + ->join('users', ',') + ->get(); + + if($data->acl == 'private') $data->users = $this->app->user->account; + if($data->acl == 'custom' && strpos($data->users, $this->app->user->account) === false) $data->users .= ',' . $this->app->user->account; $data->type = static::DOC_TYPE_API; $this->dao->insert(TABLE_DOCLIB)->data($data)->autoCheck() ->batchCheck($this->config->api->createlib->requiredFields, 'notempty') ->check('name', 'unique', "`type` = '" . static::DOC_TYPE_API . "'") ->exec(); + return $this->dao->lastInsertID(); }